Python Qualis MCQ with Answer


Python Qualis Mutliple Choice Questions with answer | Python Qualis TCS Fresco Play Answers | Python Qualis TCS Fresco play dumps | Python Qualis Objective type question with answer | Python Qualis Dumps Fresco Play

Q1.The real objective of Software testing is to ensure 100% defect free product. State true or false.
False

Q2.Which of the following is the next level of testing to unit testing?
Integration testing

Q3.Which of the following are the unit testing packages available in Python?
All of those mentioned

Q4.The testing method, which is used to test individual components of a program is known as __.
Unit testing

Q5.Why Software Testing is necessary?
All of those mentioned

Q6.Unit Testing is the highest level of testing. State true or false.
False

Q7.Which type of testing is done when one of your existing functions stop working?
regression testing

Q8.The discipline of writing tests first and then writing development code is known as __.
Test Driven development

Q9.Which type of testing is performed to check if a program is behaving as expected?
acceptance testing

Q10.The process of evaluating a software with an intent to determine if it has met the specified requirements is known as __.

Software Testing

Q11.Which of the following is a valid doctest?
def add(x,y):
“””Returns sum of two numbers.
>>>add(5,6)
13
“””
return x+y

Q12.A sample function sample_fuc is defined as shown below.

def sample_func(x, y):
“””Multiplies two given numbers and returns the product.
“””
print(x)
print()
print(y)
print()
print(x*y)
Q13.Which of the following doctest correctly tests it’s functionality?

sample_func(6,7)
6

7
<BLANKLINE.
42

Q14..Which of the following doctest directive is used to deal with unexpected whitespace that appears in the output?

doctest: +NORMALIZE_WHITESPACE

Q15.Which of the following is a docstring?
A Multiline string

Q16.A sample module named sample_module.py contained the following contents.

def mul(x, y):
“””Multiplies two given numbers and returns the product.
>>> mul(6, 7)
42
>>> mul(-8, 7)
-56
“””
return x * y

Q17.What is the expected output when you run the doctests using below command? python -m doctest sample_module.py
No output

Q18.A sample module named sample_module.py contained the following contents.

def mul(x, y):
“””Multiplies two given numbers and returns the product.
>>> mul(6, 7)
42
>>> mul(-8, 7)
>>> -56
“””
return x * y

Q19.What is the expected output when you run the doctests using below command? python -m doctest sample_module.py
Output stating 2 failures

Q20.Which of the following doctest directive is used to ignore part of the result?

#doctest: +ELLIPSIS

Q21.Which of the following special attribute can be used to access a doc string in a program?
______doc________

Q22.Which of the following doctest directive is used for not considering or executing a specific doctest?

#doctest: +SKIP

Q23.A doctest mixes documentation and testing. State true or false.
True

Q24.Which of the following is true about a docstring?

docstring is optional in a function, class or a module

Q25.Which of the following commands run only one test case , present in sample_module.py using unittest?
python -m unitest sample_module.TestCase1.test_method1

Q26.What is the parent class from which a Test class has to be derived for running it with unittest?
unittest.TestCase

Q27.unittest is a xUnit-style based unit testing framework in Python. State true or false.
True

Q28.Which of the following method is used to catch exceptions in a test, with unittest?
assertRaises

Q29.A single test module contains only one Test Class. State true or false.
False

Q30.Which of the following decorator is used to skip a test if a given condition is false, with unittest?
unittest.skipUnless

Q31.How many tests of sample_module.py shown below, are successfully passed, when run with unittest?

import unittest

class SampleTestClass(unittest.TestCase):

def test_sample1(self):
    self.assertRaises(TypeError, pow, 2, '4')

def test_sample2(self):
    self.assertRaises(Exception, max, [7, 8, '4'])

def test_sample3(self):
    self.assertRaises(ValueError, int, 'hello')

Q32.How many tests are run, when below code is tested using unittest

import unittest

def test_sample1():
assert 3 == 3

class SampleTestClass(unittest.TestCase):

def test_sample2(self):
    self.assertEqual(3, 3)

1

Q33.Which of the following statement ensures that all tests present in sample_test_module.py are run while using the command python sample_test_module.py
unittest.main

Q34.Test methods are executed alphabetically. State true or false.
True

Q35.What is the purpose of using self.id in tests, while working with unittest?
self.id returns the name of the method


Q36.How many tests are run, when below code is tested using unittest

import unittest

class SampleTestClass(unittest.TestCase):

def sample_test1(self):
    self.assertEqual('HELLO', 'hello'.upper())

def test_sample2(self):
    self.assertEqual(3*3, 9)

1

Q37.Which of the following method is used to check equality of two lists in a test, with unitest?
assertListEqual

Q38.Which of the following command is execute to run all the test cases present in a project folder using unittest?
python -m unittest discover

Q39.Which of the following decorator need to be used while working with setUpClass and tearDownClass fixtures?
@classmethod

Q40.Which of the following are the module level fixtures of unittest framework?
setUpModule, tearDownModule

Q41.Which of the following method is used to check if a regular expression matches a string or not, with unittest?
assertRegexpMatches

Q42.Which is the expected output of below code, when run using command python -m unittest sample_module.py

import unittest

class SampleTestClass(unittest.TestCase):

def setUpClass(cls):
    print('Entering Test Class')

def tearDownClass(cls):
    print('Exiting Test Class')

def test_sample1(self):
    self.assertEqual(3*3, 9)

The test run fails

Q43.Which of the following is not a component of Xunit-Style Architecture?

Test Loader

Q44.Which of the following command is used to discover all tests in a project and execute them using nose?
nosetests

Q45.Which of the following decorator is used to assign user defined setup and tear down functions to a test function, while using nose?
@with_setup

Q46.nose can recognise tests which are not part of a Test class, derived from a Parent class. State True or False
True

Q47.How many tests of sample_module.py shown below, are successfully passed, when run with nose?

from nose.tools import raises

class SampleTestClass:

@raises(TypeError)
def test_sample1(self):
    pow(2, '4')

@raises(Execption)
def test_sample2(self):
max([7, 8, ‘4’])

@raises(Exception)
def test_sample3(self):
    int('hello')

1

Q48.How many tests are run, when below code is tested using nose?

import unittest

def test_sample1():
assert 3 == 3

class SampleTestClass(unittest.TestCase):

def test_sample2(self):
    self.assertEqual(3, 3)

0

Q49.Which of the following package is required for generating test reports in html format using nose?
nose-htmloutput

Q50.Unittest Tests can be run using nose. State true or false.
True

Q51.Test discovery is simpler in unittest than in nose. State true or false.
False

Q52.Which of the following decorator is used to report a test as a failure one, if execution of it takes more than the specified number of seconds?
@timed

Q53.ok_ utility from nose.tools is equivalent to __.
assert

Q54.nose supports use of fixtures at package level. State true or false.
True

Q55.Which of the following option is used to generate test report in xml using nose?

–with-xunit

Q56.Which of the following commands run only one test case, present in sample_module.py using pytest?
py.test sample_module.py::TestCase1::test_method1

Q57.Which of the following decorator is used to transform a user defined function into a fixture using pytest?
@pytest.fixture

Q58.Which of the following command is used to discover all tests in a project and execute them using pytest?
py.test

Q59.Which of the following are the function level fixtures available in pytest?
setup_function,teardown_function

Q60.How many tests are run, when below code is tested using pytest

import unittest

def test_sample1():
assert 3 == 3

class SampleTestClass(unittest.TestCase):

def test_sample2(self):
    self.assertEqual(3, 3)

2

Q61.pytest is capable of discovering and running tests written in unittest and nose. State true or false.
True

Q62.pytest is available as a part of Python standard library. State true or false.
False

Q63.Which of the following option is used to generate Junit style test report in xml using pytest?
–junitxml

Q64.Which of the following decorator is used to skip a test unconditionally, with pytest?
@pytest.mark.skip


Leave a Reply

Your email address will not be published. Required fields are marked *