unittest:
import unittest
class MyTest( unittest.TestCase ):
def setUp( self ):
self.variable = ...
pytest:
import pytest
class MyTest:
@classmethod
def setup_class( cls ):
cls.variable = ...
More flesh, less fluff.
unittest:
import unittest
class MyTest( unittest.TestCase ):
def setUp( self ):
self.variable = ...
pytest:
import pytest
class MyTest:
@classmethod
def setup_class( cls ):
cls.variable = ...
If using unittest:
import unittest
with self.assertRaises( Exception ) as error:
...
If using pytest:
import pytest
with pytest.raises( Exception ) as error:
...
| unittest | nosetests |
| python -m unittest tests/test_something.py -v | nosetests tests/test_something.py -v |
| python setup.py test | python setup.py nosetests |