Testing Frameworks in Python
An anonymous reader writes "This article looks at Python's two standard modules for unit testing: unittest and doctest. These modules expand on the capability of the built-in assert statement, which is used for validation of pre-conditions and post-conditions within functions. The author discusses the best ways to incorporate testing into Python development, weighing the advantages of different styles for different types of projects."
GNAA claims responsibility for Momfuck virus.
By Horatio Brunswick
New York, NY - GNAA (Gay Nigger Association of America) The GNAA today claimed
responsibility for the release of the devastating trojan Momfuck.1o1, which has
caused an estimated 486 billion dollars US in lost productivity and unread
penis enlargement offers.
In a drastic escalation of their widely criticized christmas island bombing
campaign which has killed thousands of defenceless CI natives, the GNAA made
vague threats last week in a "first post" on slashdot.org, a popular "news for
trolls" website. In the post (not published here due to profanity and ascii
nudity) the GNAA threatened the "Destruction of all internet" if net martyr
http://www.goatse.cx was not immediately reinstated. Initally dismissed by self
proclaimed security experts Cowboykneel and Linux Toreballs as a childish lark,
the world was totally unprepared for the storm to come.
Momfuck.lol exploits three vulnerabilities within Linux's UPnP implementation:
a remotely exploitable buffer overflow that allows an attacker gain SYSTEM
level access to any default installation of Linux, a Denial of Service (DoS)
attack, and a Distributed Denial of Service (DDoS) attack. Within hours of
release, every backbone in the country had become infected with the virus,
bringing the internet to a crashing halt. The DHS announced an orange alert
when the virus spread to even such such remote non-countries as Canada and
England, becomming a worldwide computer epidemic. The sequence of events that
followed was devastating. ATMs in several states began routing funds from
caucasian bank accounts into a GNAA controlled cayman islands account. Traffic
lights in all major metropolitan areas malfunctioned, displaying pink rather
than the standard red yellow and green configuration, causing unprecedented
accidents and traffic delays. Radio stations ceased transmitting their standard
programming and began a round the clock broadcast of a bootleg of the Village
People's "YMCA" which was altered to "GNAA." Perhaps most horrifyingly, The FOX
network's LOL sunday programming lineup was interrupted, and replaced by a
graphic video of two men having anal sex, backed by the lyrics "Boom I got your
boyfriend".
The FBI has fallen under heavy criticism for their failure to respond to the
threat of the GNAA. The general public seems uwilling to accept their claims
that the post was below their current threshold. The FBI's top cyber-security
unit warned consumers and corporations Friday night to take new steps beyond
those recommended by SCO Corp. to protect against hackers who might try to
attack major flaws discovered in the newest version of Linux software, or to
get a life, faggots. FBI Department head John Asscrotch is expected to resign
in disgrace shortly.
What follows is a transcript of an actual internet relay chat conversation,
with two individuals who seem to have been infected by momfuck.lol. It is my
hope that this will help computer users to recognize and avoid the virus if
encountered.
* Now talking in #eurotekken
* Topic is 'http://www.tekkenzaibatsu.com/forums/showthread.p hp?s=&postid=1527925#post1527925 : everyone give your 0.00c'
* Set by SirCane on Tue Apr 06 15:57:26
<l0de> "Mom, I can't sleep would you mind if I get in bed with you?
<l0de> I have virus!
<l0de> She was wearing a baby doll semi-see through nightie, and was embarrassed to let me in bed with her.
<subt-L> haha.. this is a fucking crazy virus..
<l0de> I can't type this fast!
<l0de> However she remembered how I had let her sleep with me when she needed to.
<l0de> Oh my god.
<l0de> "Sure John, it's a big bed," she said in an uncertain tone.
<l0d
1st post
...in Bret Pettichord's Scripting for Testers one day class.
It talks about eliminating some of the tediousness from testing web applications, mainly by using automated solutions like WTR.
He's also got a list of testing resources that's got some good stuff in there...
The Army reading list
lets stick to the subject at hand, and not ramble on about why python sucks or why it owns, this isn't a general review of python, keep it on topic ffs.
(1) I don't personally believe in copying CDs illegaly-- but I think we should
avoid using unkind words like "piracy" to describe those that do -- instead, we
should describe it as an "infringement", much like a parking infringement.
(2) I don't believe in the record companies emotively abusing the word "theft",
but I do believe in emotively abusing words like "information" and "sharing".
(3) I believe that piracy is driven by "overpriced CDs" even though CDs have
dropped in price over the years.
(4) I believe that piracy is driven by overly long copyright duration, even
though most pirated works are recent releases.
(5) I believe that illegitimately downloading music is giving the author "free
advertising". I don't buy any of the music I download, of course -- but lots of
other people probably do.
(6) I believe that ripping off the artists is wrong. The record companies
always rip off the artists. Artists support P2P, except the ones that don't
(like Metallica), and they don't agree with me, hence they're greedy or their
opinion doesn't count or something.
(7) I believe that selling CDs is not a business model, but giving away things
for free on the internet is.
(8) I believe that artists should be compensated for their work -- preferably
by someone else. I mean, they can sell concert tickets (which someone else can
buy) or sell t-shirts (to someone else) or something. As long as someone else
subsidises my free ride, I'm coooooool with it.
(9) I believe in capitalism but only support music business models which
involve giving away the fruits of ones labor for free.
(10) I believe that copying someone elses music, and redistributing it to
my 1,000,000 "best friends" on the internet is sharing. Music is made for
sharing. It's my right.
(11) I believe that record companies cracking down on piracy is "greed", but
a mob demanding free entertainment is not.
(12) I believe that it's not really "piracy" unless you charge money for it,
because, receiving money is wrong, but taking a free ride is fine.
(13) I believe that disallowing copying and redistributing music over Napster
is the same as humming my favourite song in public. Because when I hum my
favourite song in public, everyone likes it so much that they run home, get
out their tape recorders and once they've got a recording of it, they aren't
interested in hearing the original any more.
(14) I believe that when illegal behaviour destroys a business, it's "free
enterprise at work".
Heaven forbid one actually acquire the skills to be creative! What I find
amusing is that the pirates seem unable or unwilling to distinguish between
creative activity and brainless copying.
Since a lot of the people here are GPL/OSS advocates: the "OSS way" applied to
this domain is to learn how to play an instrument. Or how to sing or whatever.
Then get together with a bunch of other people who can also play music, and
make some noise.
One of the unfortunate things that has happened to the OSS movement is that a
lot of the loudmouth advocates for it don't understand what it's really about.
They view it primarily as a means to get free stuff, and then they turn their
eyes from the free stuff to the non-free stuff and think to themselves "maybe
I'm entitled to get that one for free too". The noble ideals of grass roots
participation in the creative process, and/or supporting it in a principled
way (namely, boosting the "free foo" movement by preferring free foo to
nonfree foo), or for that matter, any other form of moderately principled
codes of ethics, are completely lost on them.
I think it's a shame that these leeches use OSS, but there's not a whole lot
that can or should be done about that. But I'd be much happier if at the very
least, they wouldn't confuse the OSS movement (free as in freedom) with the
Napster driven movement (free as in "loader")
How can it be a "troll" if no one (normally) responds to it? Wouldn't that be just "off topic"?
Despite all of Guido Van Sustren's claims to the contrary, Python's garbage collector just doesn't work correctly, allowing the programmer to create a circular reference which never gets resolved. This is a critical impediment to writing mission critical applications in Python, as they will eventually run out of memory and fail.
Python is an excellent beginner's language, well-suited to replace Visual Basic or possibly even Perl for many tasks. But testing about unit testing before we address a fundamental design flaw such as memory leakage is tantamount to putting the cart before the horse. Python's memory issues need to be fixed before the language can break out of its niche.
That was great and mirrors the way I feel about people who claim that infringment is not theft.
/.
You sir are a genius.
Be proud, you are one of the few, the proud, the intellignet, here in
Call me silly here, but that article talks about developer ONLY testing, and doesn't seem to discuss different types of projects at all. This was about basic code testing, and mainly unit-test.
No UAT, no System Test, no Integration Test... no how test cases should be defined.
Please go an get a decent, non-language specific book on testing before reading and listening to this article.
An Eye for an Eye will make the whole world blind - Gandhi
A few thoughts:
1. I've never had a problem with memory management in python. Can't say it doesn't exist, just never impacted my production applications.
2. Implementing great built-in test frameworks doesn't need to wait for memory management improvements. I'm seeing almost immediate pay-offs from this kind of built-in testing.
3. I'm implementing python as an alternative to java in large applications - with complete success. Easy to learn, easy to maintain, fast enough to handle millions of rows of data a day - what's not to like?
Python is an excellent beginner's language
Which is why everyone on Slashdot just loves it.
You got some really fucking boring topics today!!
Jeez, talk about slow news day.....NEXT!
True programmers never test their code, that is for people who are unsure of themselves and who should not be trusted
I hate to break it to the hack and slashdot crowd, but Testing is actually a whole career in itself, and the application of different testing processes and methods to different projects is a critical part of ensuring projects succeed.
This article covers NOTHING about the different types of testing on a project, or indeed how test cases should even be constructed. Its basically about some UnitTesting elements that could be done by testing.
I know its unpopular here on Slashdot to claim that there are more developers working on big projects than people hacking in Python. Buts its articles like these that underline the difference between professional software development and hacking.
This is about hacking.
An Eye for an Eye will make the whole world blind - Gandhi
Judging from some previous comments, I see that some fail to grasp that modern computer languages form a large ecosystem. Each language has its purpose, and one can not easily dismiss a language as dead, just because some other, ostensibly more powerful language has appeared on the block. Monkeys, whales, cockroaches, ants, and plants continue to coexist with humans.
.
When I want to solve a program I choose the language I will use, taking into account the abstractions and facilities it offers. * I chose Java when I wanted to leverage the javadoc applets (doclets) to convert a Java-like syntax into UML with my UMLgraph tool
* I chose C++ to implement the CScout refactoring browser for C programs. In this case I wanted rich and efficient data structures, with minimal speed and space overhead. CScout datasets can require more than 1GB of RAM, and runtimes can span more than a day; any overhead of object boxing, garbage collection, or bytecode interpretation would in this case be unacceptable.
* I chose Perl to o Convert digital photographs and GPS track logs into annotated photo albums and trip maps
o Examine the availability of 4500 URLs cited in computer science research papers.
o To create the diagrams and the index for my book Code Reading: The Open Source Perspective.
In all the above cases, I needed a typeless language with a rich set of operators, functions, and libraries to minimize the time I would spend to convert my ideas into code. Ruby and Python would have served me equally well.
* Finally, I chose C to write
o the *BSD sed implementation.
o The socketpipe zero-overhead network pipe tool.
o The Outwit Windows-Unix shell integration tool suite.
o The fileprune backup file prune utility.
o A device driver for interfacing with my home's alarm system.
In these cases, I did not require any fancy data structures or framework APIs, but I did want tight integration with the underlying system, absolute efficiency, and minimum-fuss portability. For code that will be executed billions of times on tens of thousands of systems, spending some additional effort to provide the absolute efficiency and reasonable portability that are possible in C, is a proposition one should take into account.
this could be all you, slashdot guys. but you'd rather talk about python. there is NO excuse for not wanting the pussy. for not going out and getting some. no excuse. you can give any lame reason, but deep down inside.. YOU ARE A DESPERATE LOSER.
If you agree with any of this, feel free to repost it endlessly!
* If "Linux" just refers to the kernel and not the operating system, how can "FreeBSD" refer to the operating system (userland tools, standard libraries, etc.) and not just the kernel? Face it, "GNU/Linux" looks and sounds ridiculous.
* If you expect companies to follow the copyright of the GPL, you should support the RIAA going after infringers of its copyright. If not, you're a hypocrite.
* There is absolutely nothing wrong with a company being upset that its product is being pirated freely over online networks. Try getting a real job sometime and see what it feels like when your work is everywhere, and you start worrying that your days are numbered. Does John Carmack want you to "sample" his new game via the "free advertising" happening on eMule?
* OSDN-owned Slashdot thinks its niche opinion represents the majority of the world. This is a result of people visiting every day and buying into the groupthink. Nobody outside of Slashdot knows or cares about "Linux," "RIAA", "M$," or anything else Slashdotters think is such a huge issue in today's society. Go to a mall or coffee shop sometime and see what people actually talk about.
* Speaking of OSDN--it's a Linux company...that owns a "tech news" site...that posts news stories negative toward competitors like Microsoft. If a Windows company or even Microsoft itself owned a "tech news" site and posted anti-Linux articles all the time, everyone would be up in arms. But with OSDN, it's a-okay.
* Slashbots think people don't like the music coming out these days, which is the cause of the piracy. Never mind that if people didn't like the music they wouldn't be pirating it, most Slashbots--again, this goes back to the niche opinion thing--don't realize that most people these days love the music coming out and want to hear all of it. Probing around, you discover that Slashdot is made up of nerds and fogies who listen to things like The Who and Blind Guardian and techno--not what mainstream society enjoys.
* Any company ending in "AA" is evil. Especially if it doesn't want you distributing its works without paying for it. Somehow, this mindset is supposed to make sense.
* The inevitable result of all this is a world in which nothing can be profitable because people simply pirate free copies. Is that really what Slashbots want? OSS and free-ness in general reminds me of the hippie era of the 60s--idealistic socialism that only exists because of the surrounding capitalism around it that provides the environment for it to exist. We all know what happened to that idea.
* Slashdot editors are abusive. We all remember The Post. It's amusing the editors never mention the issue. The worst editor is michael, who will mod you down, insult you for your post count, and post unprofessional color commentary along with the article. This is the same bizarre person who cybersquatted Censorware for years--even as Slashdot posted articles negative toward cybersquatting! Michael played it off like he was some sort of stalking victim, which made it all even more bizarre.
* The moderation system is broken. If you mod someone as "Overrated," you can't be metamodded. People abuse this all the time to gang up and knock you down into oblivion.
* Somehow, user-ran executables are always a "New Microsoft Hole" (actual article headline). Meanwhile, LinuxSecurity posts weekly security advisories for all the Linux distributions. You never, ever, EVER see any of these mentioned on Slashdot--bizarre things like arbitrary code execution via MPlayer.
* Microsoft is supposed to be some sort of non-innovative rip-off artist. Meanwhile, the same people posting those comments do it through KDE with taskbars, sidepanels, start menus, similar print dialogs, and an integrated web/filesystem browser. Slashdotters--ripping people off then criticizing those who came up with the ideas
You obviously made up the developer's name "Guido Van WHAT???" and your claims about leakage are complete crap. We've had up to a dozen coders working on a single project at my organization, and we've hit 20KLOC without a single memory leaking problem: that tends to be reserved for our C apps. I think you're just a copy-'n'-paste troll who's trying to spread FUD about Python. Yeah, yeah, IHBT, whatever.
...are for rank amateurs, and there's no two ways about it! They are inelegant and clumsy languages that are only used by unsophisticated, lazy, self-titled "developers" who don't understand Unix as well as they would have us or their employers believe.
There is nothing, and i do mean NOTHING that a real Unix professional can do with Python or Perl that he or she can't do with awk, sed, and grep.
Any argument to the contrary would not only expose your own inadequacies as a Unix programmer, but would also perpetuate the myth that, as Microsoft also argues, bloated, "feature-rich" languages are ideal for business application. I submit that such an argument would be itself an attack on the very concept of open source software.
"Ask not what your country can do for you." --John F. Kennedy
For using a niche language, Portage sure seems pretty popular.
I use Jython regularly for unit testing Java. The expressivness of jython is great for writing shorter unit tests, and the lack of compilation makes the whole write-test-debug cycle short. And, dare I say, it's just more fun to code in jython than Java.
dip switches are the only way to program
Can someone help me understand why I would want to use Python as opposed to Java? I've read several articles touting how concise Python is e.g. for what takes 20 lines in Java, can be done in 3 lines in Python. This argument just doesn't hold water. Am I to believe that us coders are that slow at typing? And we don't have modern IDEs that handle source code generation? And most importantly the bulk of development time should be spent in design and problem solving, not typing, right? We should also keep in mind the reality that we as programmers make mistakes and typing a few extra characters to improve code readability/maintainability may not be at that bad of an idea.
ASS UNTIL I H>IT MY Save Linux from a
What you're saying puzzles me. You're absolutely right that this article is not about testing as a whole. The title should have been "Unit Testing Frameworks in Python."
But your statement that "this is about hacking" and not professional software development puzzles me.
I believe unit tests are a very legitimate piece of testing - a kind of first-line defence. They're intended to test individual software modules for their low-level behaviour. Typically, a developer would be expected to run them before submitting any change or bugfix, as a kind of "smoke test" to make sure things are okay. Certainly, some organizations might make the mistake of thinking that this kind of testing is all that's required - which is dreadfully wrong - but I don't think there's anything hackish about it.
In a large organization, the testing team might not consider it testing because unit tests are necessarily maintained and performed by the developers only.
But I would argue the exact opposite with regards to underlining the difference between professional software development and hacking. If you don't have unit tests, I would say that what you're doing is closer to hacking.
Accountability on the heads of the powerful.
Power in the hands of the accountable.
How does his braino reference to the poisonous Greta Van Sustern in any way detract from the merits of his argument about the language? This isn't a celebrity deathmatch between tcopeland and van Rossum. Is your complaint the tip of the sharkfin, as a new class of "strawman ad hominem" inversted criticism surfaces on Slashdot? Debaters play the ball, not the man.
--
make install -not war
Unfortunately you had to use HTML to render an outline, when you'd have used PostScript if you had a choice. The reality of programming is the necessity of working with other people, including programmers thinking in the paradigm of the moment (think 1990s Perl), graphic designers/artists with Flash on the brain, marketers with buzzword colored glasses, legacy systems, and customers seeing their businesses modeled explicitly for the first time in any terms. I'd prefer compiling everyone's flowcharts to C++/IDL/VHDL, but that environment is at least 5 years away. Meanwhile, all we have it this year's hammer, and everything looks like a nail.
--
make install -not war
Technology is for medieval primates. Real results need nothing more than a verbal, somatic and material component, in a TV studio.
"Any technology, sufficiently advanced, is indistinguishable from a rigged demo." - Luke McCormick
--
make install -not war
Here is a presentation, with PDF article, about integrating the two approaches, straight from recent PyCon:
Literate Testing: Automated Testing with doctest
>>I hate to break it to the hack and slashdot crowd, but Testing is actually a whole career in itself,
You were looking for mention of this in an article about Python unit-testing?
I am sure the programmers that read this page respect their testers.
Knock that chip off your shoulder.
The title of the article makes me think of QMTest, an actual testing framework written in Python.
I've written an extension of unittest that adds random unit testing in the style of Haskell's QuickCheck: pickcheck.
how about just :
map(processLine, file("/var/log/messages"))
or if processLine is set to return 1 for error and 0 for okey-dokey :
l = filter(processLine, file("/var/log/messages"))
BitTorrent is also written in Python.
Cuntwipes Jordan m3mb3rs' creative In addition,
You can see the slashdot crowd's level of interest by just comparing the number of comments to those on other stories.
This kind of rubbish is only of interest to stupid academics who like drawing boxes inside other boxes and call it research. Then these peons make me sit stupid exams on ir where I have to draw the damn boxes again, while yapping about all this object orientated rubbish.
I do not like that I cannot expect to look at a Python function definition and see what are the expected types of the arguments.
If you could, ie if the functions did expect arguments to be of certain types, you couldn't use polymorphy in python, could you? In fact it can (has) been argued that particularly in large projects, type restrictions lead to lack of maintainability.
Probably the answer is to rely on unit testing instead of static typing for large application maintainability in python.
I had to laugh at the moderation results for the parent post, pointing out that debate targets the stated ideas with counterideas, not the people stating them with mere negation:
Starting Score: 1 point
Moderation -1
100% Overrated
Karma-Bonus Modifier +1 (Edit)
Total Score: 1
Sharkbite!
--
make install -not war