Any2Quiz
Computer Science / Languages / Python

Testing Quiz - Languages Python

Free practice quiz: Testing (Languages Python). 52 multiple-choice questions with answers and explanations. Play online, no sign-up needed.

Play all 52 questions free

Sample questions

  1. Which of the following is a common testing framework in Python used for unit testing?

    1. Pytest
    2. Nose
    3. Unittest
    4. All of the above
    Show answer

    Answer: D. All of the above

    Python has several popular testing frameworks. 'unittest' is part of the standard library, 'pytest' is a widely adopted third-party framework known for its simplicity and powerful features, and 'Nose' (or Nose2) is another established framework. All three are commonly used for unit testing.

  2. Which of the following is a type of testing that verifies the behavior of individual units of source code?

    1. Unit Testing
    2. Integration Testing
    3. System Testing
    4. Acceptance Testing
    Show answer

    Answer: A. Unit Testing

    Unit testing focuses on testing the smallest testable parts of an application, typically functions or methods, in isolation.

  3. In Pytest, how can you run tests that are marked with a specific name?

    1. `pytest -m marker_name`
    2. `pytest --select marker_name`
    3. `pytest mark marker_name`
    4. `pytest run -m marker_name`
    Show answer

    Answer: A. `pytest -m marker_name`

    The `-m` flag in Pytest is used to select tests based on their assigned markers. This allows for categorizing and running specific groups of tests.

  4. What is a 'test case'?

    1. A set of conditions or variables under which a tester will determine whether a system under test satisfies requirements or works correctly.
    2. A framework for executing tests.
    3. A collection of test suites.
    4. A tool for reporting test results.
    Show answer

    Answer: A. A set of conditions or variables under which a tester will determine whether a system under test satisfies requirements or works correctly.

    A test case is a detailed description of a series of actions, inputs, and expected outputs to verify a specific feature or functionality of the software.

  5. In Pytest, what is the purpose of `pytest.mark.parametrize`?

    1. To run a single test function multiple times with different arguments.
    2. To mark a test as belonging to a certain category.
    3. To skip tests that meet certain criteria.
    4. To define test fixtures.
    Show answer

    Answer: A. To run a single test function multiple times with different arguments.

    `pytest.mark.parametrize` is a decorator used to run a test function with multiple sets of arguments, making it a powerful tool for data-driven testing.

Take the full quiz

More quizzes

Browse all Python quizzes