About 2,870,000 results
Open links in new tab
  1. python - Running unittest with typical test directory structure

    The very common directory structure for even a simple Python module seems to be to separate the unit tests into their own test directory: new_project/ antigravity/ antigravity.py te...

  2. python - Write unittest for console print - Stack Overflow

    69 This Python 3.6 answer uses unittest.mock. It also uses a reusable helper method assert_stdout, although this helper is specific to the function being tested.

  3. Python unit test with base and sub class - Stack Overflow

    I currently have a few unit tests which share a common set of tests. Here's an example: import unittest class BaseTest(unittest.TestCase): def testCommon(self): print 'Calling BaseTest:

  4. python - Running a single test from unittest.TestCase via the …

    python -m unittest mypkg.tests.test_module.TestClass.test_method would always work, without requiring you to have that if __name__ == "__main__": unittest.main() code snippet in your …

  5. Disable individual Python unit tests temporarily - Stack Overflow

    Feb 22, 2017 · How can individual unit tests be temporarily disabled when using the unittest module in Python?

  6. How do you test that a Python function throws an exception?

    Sep 25, 2008 · On Python < 2.7 this construct is useful for checking for specific values in the expected exception. The unittest function assertRaises only checks if an exception was raised.

  7. Newest 'python-unittest' Questions - Stack Overflow

    Sep 29, 2025 · I'm using basedpyright for static type checking, and it fails to resolve imports from a test utility module located under the tests directory. However, unittest executes the tests …

  8. Python unittest setting a global variable correctly

    Python unittest setting a global variable correctly Asked 5 years, 8 months ago Modified 5 years, 8 months ago Viewed 24k times

  9. abstract test case using python unittest - Stack Overflow

    Take note of a common pitfall: in case you override TestCase method in Abstract (overriding "setUp" is the common case), you want to reverse the order of base classes - class …

  10. python - unittest vs pytest - Stack Overflow

    In unittest, I can setUp variables in a class, and then the methods of this class can choose whichever variable it wants to use... class test_class(unittest.TestCase): def setUp(self): ...