-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Ensure unittest example MyTestCase
can be run
#126864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Do you mean there should be an |
I think there are some places where we could add dummy objects. For instance: class MyTestCase(unittest.TestCase):
@unittest.skip("demonstrating skipping")
def test_nothing(self):
self.fail("shouldn't happen")
@unittest.skipIf(mylib.__version__ < (1, 3),
"not supported in this library version")
def test_format(self):
# Tests that work for only a certain version of the library.
pass
@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
def test_windows_support(self):
# windows specific testing code
pass
def test_maybe_skipped(self):
if not external_resource_available():
self.skipTest("external resource not available")
# test code that depends on the external resource
pass However, we say "This is the output of running the example above in verbose mode:" which is incorrect. Instead, let's replace For the Widget test, I don't think we need to add a Widget implementation because it'd be too painful to write IMO. We also don't specify the output and don't say "if your run this, you get that". Note that we already had some E2E test with |
MyTestCase
can be run
Documentation
https://docs.python.org/3/library/unittest.html#organizing-test-code
In the examples test functions create instance of Widget class but there is no import for the class.
It is impossible to write unit tests without knowing how to import the modules you are about to test, so it would be nice to see how it is actually done.
The text was updated successfully, but these errors were encountered: