Which statement correctly describes how PyTest and unittest discover tests?
Think about which framework is known for simpler test discovery without extra setup.
PyTest automatically discovers tests by scanning files and functions starting with 'test'. unittest can discover tests but often requires defining test suites or following strict naming conventions.
Given the following test code, what is the main difference in output when the assertion fails in PyTest compared to unittest?
def test_example(): assert 1 == 2 import unittest class TestExample(unittest.TestCase): def test_example(self): self.assertEqual(1, 2)
Consider which framework provides more readable failure details by default.
PyTest enhances assertion introspection, showing exact values and differences on failure. unittest shows a more basic failure message unless customized.
In PyTest, which locator is the best practice to select and run a specific test function named test_login_valid inside test_auth.py?
Think about the syntax to run a specific test function in a file.
The syntax pytest filename::test_function runs the specific test function. Option B runs tests matching the keyword but may run multiple tests.
Which assertion statement is valid in unittest but will cause an error in PyTest?
Consider which assertion methods require a class instance.
unittest assertions like self.assertEqual() require a TestCase class instance. PyTest uses plain assert statements and does not support self.assertEqual() outside classes.
You have a large legacy Python project with many tests using unittest.TestCase classes and complex setup/teardown methods. You want to gradually migrate to a more modern testing framework without rewriting all tests at once. Which framework is the best choice?
Consider which framework supports running existing unittest tests without rewriting.
PyTest can run unittest.TestCase tests without changes and supports fixtures for new tests, enabling gradual migration. nose is outdated and less maintained. Rewriting all tests at once is risky and time-consuming.