python unit test new Flashcards

1
Q

perform unit test

A

assertEqual(a, b)

a == b

assertTrue(x)

bool(x) is True

assertIs(a, b)

a is b

assertIn(a, b)

a in b

assertIsInstance(a, b)

isinstance(a, b)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

AssertEqual
(first, second, msg=None)

A

Test that first and second are equal. If the values do not compare equal, the test will fail.

In addition, if first and second are the exact same type and one of list, tuple, dict, set, frozenset or str or any type that a subclass registers with addTypeEqualityFunc() the type-specific equality function will be called in order to generate a more useful default error message (see also the list of type-specific methods).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

assertTrue(expr, msg=None)

A

Test that expr is true (or false).
**testing method to check if calculation is true or false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

assertIs(first, second, msg=None)

A

Test that first and second are equal. If the values do compare not equal, the test will fail.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

assertIn(member, container, msg=None)

A

Test that member is (or is not) in container.
** assertin method to see if an item is within a list of items

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

assertisinstance

A

assertisinstance testing method if an object is instance of a class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly