O'Reilly logo

Python Testing Beginner's Guide by Daniel Arbuckle

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - using Nose-specific tests

We'll write a few tests that demonstrate Nose's support for test functions and non-TestCase test classes.

  1. Create a file called nose_specific_tests.py with the following contents:
    import sys from sqlite3 import connect class grouped_tests: def setup(self): self.connection = connect(':memory:') cursor = self.connection.cursor() cursor.execute('create table test (a, b, c)') cursor.execute('''insert into test (a, b, c) values (1, 2, 3)''') self.connection.commit() def teardown(self): self.connection.close() def test_update(self): cursor = self.connection.cursor() cursor.execute('update test set b = 7 where a = 1') def test_select(self): cursor = self.connection.cursor() cursor.execute('select * from test ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required