I am looking for an elegant way to run unit tests on multiple data, in this case a directory containing text files .  Consider a folder text containing several txt files, I want run this example unittest on each file ( for example by feeding a list of files from glob to my unittest )  Here is how I test a single hardcoded file .  import unittest import parser  class TestParser(unittest.TestCase):     text_path = 'text/journal.txt'      def test_get_chapters(self):         x = parser.get_chapters(self.text_path)         self.assertGreater(len(x),1))  if __name__ = "__main__":     unittest.main()    Thanks !!
I have some kind of test data and want to create a unit test for each item. My first idea was to do it like this: import unittest  l = [[&quot;foo&quot;, &quot;a&quot;, &quot;a&quot;,], [&quot;bar&quot;, &quot;a&quot;, &quot;b&quot;], [&quot;lee&quot;, &quot;b&quot;, &quot;b&quot;]]  class TestSequence(unittest.TestCase):     def testsample(self):         for name, a,b in l:             print &quot;test&quot;, name             self.assertEqual(a,b)  if __name__ == '__main__':     unittest.main()  The downside of this is that it handles all data in one test. I would like to generate one test for each item on the fly. Any suggestions?
The message that appears in the reputation tab of a user's profile when they gain or lose reputation due votes disappearing when another user is deleted is simply:     user was removed   This message is confusing and unhelpful. Below are comments that demonstrate this confusion, . I don't have any quotes from the users who could not find it and remained confused.  There is , and . However, the message has not been changed.  I know that in the past the developers have been reluctant to direct users to meta in some situations, such as question bans, because it may cause users to post here appropriately. That does not seem to apply to this case. This is not typically a case of ""; most of us have probably seen the message at some point.  Why is this message vague and unlinked? What negative behaviour does this confusion mitigate?       My first interpretation was that I was the user who was removed!        I just simply wished the explanation on the reputation page was better. Seems like I shouldn't have had to come to the meta section to figure this out.        It must be better to show "User  was removed". For a moment I just thought that I was removed :-(        the information should be better. I lost 10 points yesterday by "user removed" and assumed that I was the one being removed, leaving me wondering why and feeling somewhat embarrassed.         The recalc policy is fine. But the red mark and "user was removed" looks cryptic and unnecessarily negative--especially since the only user name mentioned on a profile is one's own. So the natural impulse is to bind "user" to the account you're looking at. (It was jarring to me and I could tell what it meant, but still this could be clearer.) I agree that orange is better than red and ideally all of these things would have hyperlinks to a help page (or at least a meta post) explaining what the deal is.        +1 (to HostileFork) for the idea of linking to an explanation of 'User was removed'. It just took me 10+ minutes to find this particular thread and read through, when I could have simply clicked through! I would also like a little more info on why user was removed (abuse, friend upvotes, rules, etc) , as that could help educate the community as a whole on what behaviors to report.        I could care less about the rep gain or loss, but when you have a loss it is a scary message without context. I honestly thought for a moment that my account had been inhibited in some way. No, it didn't say "Your account was removed." Still, there is that moment of "what did I do wrong?" which seems silly to cause simply by not posting a few extra words. A clearer "A user who voted on your posts was removed along with reputation changes they caused" would have gone a long way to not cause me to question my participation in the review queues as of late.         My problem is that the message "user has been removed" is not a clickable link like the other messages - so I had to search meta to discover this question to find out what it meant. Does adverb placement affect meaning? He swam slowly to the island.  He slowly swam to the island.    Some experts say that there is a “slight difference” in meaning. Would you please tell me that difference? I know this is a total noob question but then again, when it comes to PostgreSQL I am a total noob...    I have installed the OpenGeo suite on my computer, running Windows 7, 64-bit.  I have downloaded the tutorial data and have been working through it.  I would like to access the database that I have made with ArcGIS so I can start learning about how that works.  However, when I try to connect to the database using the "Add Database Connection..." I can't seem to figure out what to put in for 'Instance' - everything I've tried (localhost, localhost,54321, my IP address with and without the port, my computer name) doesn't seem to work.  I installed and created the nyc test database according to all the instructions in the OpenGeo tutorial pages but am at a total loss here.  I know this must be an easy thing to deal with, I just can't get my head around it.  Can someone with more experience throw me a bone on this one?    Frustratingly enough, QGIS connects to the database with almost no effort and everything works fine - but my organization is heavily ESRI focused and switching to QGIS is a long shot...  EDIT Thanks everyone for pitching in on this.  I really appreciate the advice, it's what makes this site great.  I have installed    OpenGeo Suite 3.0.1 with no extensions ArcGIS Desktop 10.1, no license for server   I just went to the Opengeo website and downloaded the Windows installer and installed the default configuration. I have tried every permutation for the instance name that I can think of - using colons and commas, my machine name, localhost, postgresql, server, my IP address, random curse words, anything I can think of.  I have been using port 54321 instead of 5432 because that is what the OpenGeo workshop told me to set up my 'nyc' practice database to use.    It seems that localhost should work, here is a shot of the server properties from pgAdmin: How do I determine if my integrated Intel graphics support "Shader Model 3"? I am trying to play a Steam game on Ubuntu.  The game requires "Graphics: Shader model 3".  How do I determine if my integrated Intel graphics support Shader Model 3?  At present, when I launch the game, I hear the audio, but the screen is entirely black.  Running glxinfo | grep OpenGL yields:  OpenGL vendor string: Intel Open Source Technology Center OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile  OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.2.2 OpenGL core profile shading language version string: 4.50 OpenGL core profile context flags: (none) OpenGL core profile profile mask: core profile OpenGL core profile extensions: OpenGL version string: 3.0 Mesa 18.2.2 OpenGL shading language version string: 1.30 OpenGL context flags: (none) OpenGL extensions: OpenGL ES profile version string: OpenGL ES 3.1 Mesa 18.2.2 OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10 OpenGL ES profile extensions:   I am not sure which (if any) of the above lines answer my question. I'm having this XML document with namespaces and I want to extract some nodes using XPath.  Here's the document:  &lt;ArrayOfAnyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/"&gt;   &lt;anyType xsi:type="Document"&gt;     &lt;Id&gt;5&lt;/Id&gt;     &lt;Title&gt;T1&lt;/Title&gt;   &lt;/anyType&gt;    &lt;anyType xsi:type="Document"&gt;     &lt;Id&gt;15&lt;/Id&gt;     &lt;Title&gt;T15&lt;/Title&gt;   &lt;/anyType&gt; &lt;/ArrayOfAnyType&gt;   What's the XPath expression going to be if I want to extract all "anyType" elements with xsi:type="Document"?  I've tried this:   //anyType[@xsi:type="Document"]   and it doesn't work: I am trying to write an if statement to test whether there are any files matching a certain pattern. If there is a text file in a directory it should run a given script.  My code currently:  if [ -f /*.txt ]; then ./script fi   Please give some ideas; I only want to run the script if there is a .txt in the directory. Elementary argument for conservation laws from symmetries *without* using the Lagrangian formalism It is well known from Noether's Theorem how from continuous symmetries in the Lagrangian one gets a conserved charge which corresponds to linear momentum, angular momentum for translational and rotational symmetries and others.  Is there any elementary argument for why linear or angular momentum specifically (and not other conserved quantities) are conserved which does not require knowledge of Lagrangians? By elementary I mean, "if this is not so, then this unreasonable thing occurs".   Of course, we can say "if we want our laws to be the same at a different point in space then linear conservation must be conserved", but can we derive mathematically the expression for the conserved quantity without using the Lagrangian?  I want to explain to a friend why they are conserved but he doesn't have the background to understand the Lagrangian formalism. Show that if $f: \mathbb{R} \to \mathbb{R}$ is a continuous injective map, then it is strictly monotonic.    Could someone give me a proof for this? I have the intuition for why it's true - I'm just having trouble expressing that intuition in a rigorous manner. Basically consider two points $x_1, x_2 \in \mathbb{R}$. By the problem statement, $f$ is continuous on $[x_1, \, x_2]$. WLOG, assume that $f$ is strictly increasing. It there exists a point where it is not increasing, then $f$ hits a value twice, and it's not injective. Identification of particles and anti-particles The identification of an electron as a particle and the positron as an antiparticle is a matter of convention. We see lots of electrons around us so they become the normal particle and the rare and unusual positrons become the .  My question is, when you have made the choice of the electron and positron as particle and anti-particle does this automatically identify every other particle (every other fermion?) as normal or anti?  For example the proton is a particle, or rather the quarks inside are. By considering the interactions of an electron with a quark inside a proton can we find something, e.g. a conserved quantity, that naturally identifies that quark as a particle rather than an antiparticle? Or do we also just have to extend our convention so say that a proton is a particle rather than an antiparticle? To complete the family I guess the same question would apply to the neutrinos. Why "grand theft auto", not "grand auto theft"? There is a video game series called "Grand Theft Auto".  According to its :     The name of the series references the term used in the US for motor   vehicle theft.      [...]      Motor vehicle theft or, grand theft auto, is the criminal act of   stealing or attempting to steal a car (or any other motor vehicle).   I always wondered why this term sounds so strange.   Shouldn't it be "grand auto theft" or maybe "grand theft of auto" instead? Are there any other terms with strange words order and/or missing prepositions like this? Why do gases have weight? I know that a gas is made of atoms or molecules moving freely in space.  When these particles hit the walls of where they're kept in they cause something called pressure.  But these particles never pile up on each other and push a surface down by their weight so that we can measure it as weight, not pressure.  So why do gases have weight? The actual question was to find the area bounded by the curve $y=\int_{-1}^{1}(1-x^2)^ndx$ and coordinate axes. But I haven't came across these type of problems with power $n$. How do suggested edits work? When clicking &quot;edit&quot; I see:  Your edit will be placed in a queue until it is peer reviewed. We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.  Like:     Likewise, when I am not logged in, clicking &quot;improve this question&quot; or &quot;improve this answer&quot; shows:  You are not . Your edit will be placed in a queue until it is .  And when I click 'Save', I get:  Thanks for submitting an edit. It is only visible to you until it's been approved by trusted community members  Like:     Who can suggest an edit? Where do suggested edits go? Who can vote on a suggested edit? How do suggested edits get reviewed? Can I earn reputation? What about abuse or bad edits? Sometimes the Community user approves or rejects my edit. Why is that? When can I not suggest an edit? Is there a minimum change requirement for a suggested edit? How do I check my suggested edit history? I disagree with the reasons why my suggested edit was rejected. What can I do? How do I know whether there are edits waiting for review? Someone suggested an edit to my own post, and the reviewers took the wrong action. What can I do? Are tag wikis included in this scheme? What do the &quot;Improve Edit&quot; and &quot;Reject and Edit&quot; buttons do? Why are apparently valid links to rejected edits resulting in 404 errors?   For more information about editing, see &quot;&quot; in the . One of our SQL Server 2014 database transaction logs is growing very fast and I cannot find the root cause for this.  Database in Simple recovery mode. During full backup the log file grows to its limits (800GB) and backup fails.  I checked the transactions during the backup and did not find anything strange.  All transactions are our regular loading and no maintenance jobs (index rebuilds etc.)  I am aware of that backup keep the log from reuse but this mean 800GB changes during the backup period and this does not make any sense.  I had compared this DB to similar DB size, loading and backup duration. The second DB Log is not growing more than 400GB.  DB size is 7TB. Backup time is ~20H. The only time log is growing is during backup. Log_reuse shows correct Backup_Restore. No long running transactions.  The problem is the "speed" of log growth - compared to similar sites with same load and same backup duration, the log is 4 time less. If space of bounded operators L(V,W) is Banach, V nonzero, then W is Banach (note direction of implication) Let $V,W$ be normed vector spaces, and $L(V,W)$ be the space of bounded linear operators. Usually I would only see the statement "If $W$ is Banach, then $L(V,W)$ is Banach.". But  writes that there is a converse: "If $L(V,W)$ is Banach, and if $V$ is non-trivial, then $W$ is Banach". This is pretty interesting since I never seen a converse before. I was wondering if anyone has a nice proof.  I tried reversing the proof for the usual direction, but the inequalities can't be reversed. I also tried to start with a Cauchy sequence in $W$, and construct linear operators (using Hahn-Banach to control the operator norms), but alas I cannot say much about the distance between these operators (much less say that it is Cauchy) How can you convert a byte array to a hexadecimal string, and vice versa? Clear item with custom name? I am trying to grow my C: drive to use the unallocated space on Disk 0. Is it safe to throw away the Recovery Partition (i.e. make it unallocated)? And if so, is GParted an ok tool to do that with? Or do I need to move that, and if so, is the way to do that to reduce the size of the unallocated partition so there is empty space at the end, then move it there? guess the color of the next card There are 26 red cards and 26 black cards on the table which are randomly shuffled and are facing down onto the table. The host turns up the cards one at a time. You can stop the game any time (even at the beginning of the game). Once you stops the game, the next card is turned up: if it is red, you get $1; otherwise you pay the host one dollar. What is the payoff of this game? Tourist to F1 change of status within 60 days I have a PhD place at a US university starting Aug 21 but want to visit a different university for casual research for 6 weeks from July 1. This is longer than the 30 day grace period for the F1. Can I arrive on the visa waiver program or tourist visa in July and then just stay on for the PhD? I guess I might need to change status. Will this work?  Please don’t suggest exiting and reentering, that’s too expensive.  (British masters student in UK)