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

    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 unittest: how to run only part of a test file?

    Jul 1, 2009 · Use of the classes unittest.TestLoader and unittest.TestSuite In the file test_prod.py I have used the classes TestLoader and TestSuite of the unittest module to complete the test code and …

  3. 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.

  4. 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:

  5. python - Running a single test from unittest.TestCase via the command ...

    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 test …

  6. Python unittest setting a global variable correctly

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

  7. 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.

  8. Python unittest: replace (or patch) a function via mock

    Jan 10, 2021 · I simply replace a function before a test and set it back to the original one at the tests end - without using unittest.mock. The question is how can I replace the function or modify the return …

  9. Python unittest passing arguments - Stack Overflow

    In Python, how would I pass an argument from the command line to a unittest function? Here is the code so far… I know it's wrong. class TestingClass(unittest.TestCase): def testEmails(self): ...

  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): ...