module pycode.unittestclass

Inheritance diagram of pyquickhelper.pycode.unittestclass

Short summary

module pyquickhelper.pycode.unittestclass

Overwrites unit test class with additional testing functions.

source on GitHub

Classes

class

truncated documentation

ExtTestCase

Overwrites unit test class with additional testing functions. Unless setUp is overwritten, warnings FutureWarning

Functions

function

truncated documentation

skipif_appveyor

Skips a unit test if it runs on appveyor.

skipif_azure

Skips a unit test if it runs on azure pipeline.

skipif_azure_linux

Skips a unit test if it runs on azure pipeline on linux.

skipif_azure_macosx

Skips a unit test if it runs on azure pipeline on linux.

skipif_circleci

Skips a unit test if it runs on circleci.

skipif_linux

Skips a unit test if it runs on linux.

skipif_travis

Skips a unit test if it runs on travis.

skipif_vless

Skips a unit test if the version is stricly below version (tuple).

unittest_require_at_least

Skips a unit test if the version of one module is not at least the provided version.

Static Methods

staticmethod

truncated documentation

_format_str

Returns s or 's' depending on the type.

Methods

method

truncated documentation

assertCallable

Checks that fct is callable.

assertEmpty

Checks that x is empty.

assertEndsWith

Checks that string sub ends with whole.

assertEqual

Checks that a == b.

assertEqualArray

Checks that two arrays are equal. Relies on numpy.testing.assert_almost_equal.html.

assertEqualDataFrame

Checks that two dataframes are equal. Calls pandas.testing.assert_frame_equal.

assertEqualDict

Checks that a == b.

assertEqualFloat

Checks that abs(a-b) < precision.

assertEqualNumber

Checks that two numbers are equal.

assertEqualSparseArray

assertExists

Checks that name exists.

assertGreater

Checks that x >= y.

assertLesser

Checks that x <= y.

assertNotEmpty

Checks that x is not empty.

assertNotEndsWith

Checks that string sub does not end with whole.

assertNotEqual

Checks that a != b.

assertNotEqualArray

Checks that two arrays are equal. Relies on numpy.testing.assert_almost_equal.html.

assertNotEqualDataFrame

Checks that two dataframes are different. Calls pandas.testing.assert_frame_equal.

assertNotExists

Checks that name does not exist.

assertNotStartsWith

Checks that string sub does not start with whole.

assertRaise

Checks that function fct with no parameter raises an exception of a given type.

assertStartsWith

Checks that string sub starts with whole.

capture

Runs a function and capture standard otuput and error.

fLOG

Prints out some information. fLOG().

profile

Profiles the execution of a function.

read_file

Returns the content of a file.

setUp

Filters out FutureWarning, PendingDeprecationWarning.

tearDown

Stops filtering out FutureWarning, PendingDeprecationWarning.

write_file

Writes the content of a file.

Documentation

Overwrites unit test class with additional testing functions.

source on GitHub

class pyquickhelper.pycode.unittestclass.ExtTestCase(methodName='runTest')[source][source]

Bases: unittest.case.TestCase

Overwrites unit test class with additional testing functions. Unless setUp is overwritten, warnings FutureWarning and PendingDeprecationWarning are filtered out.

source on GitHub

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

static _format_str(s)[source][source]

Returns s or 's' depending on the type.

source on GitHub

assertCallable(fct)[source][source]

Checks that fct is callable.

source on GitHub

assertEmpty(x, none_allowed=True)[source][source]

Checks that x is empty.

source on GitHub

assertEndsWith(sub, whole)[source][source]

Checks that string sub ends with whole.

source on GitHub

assertEqual(a, b)[source][source]

Checks that a == b.

source on GitHub

assertEqualArray(d1, d2, **kwargs)[source][source]

Checks that two arrays are equal. Relies on numpy.testing.assert_almost_equal.html.

source on GitHub

assertEqualDataFrame(d1, d2, **kwargs)[source][source]

Checks that two dataframes are equal. Calls pandas.testing.assert_frame_equal.

source on GitHub

assertEqualDict(a, b)[source][source]

Checks that a == b.

source on GitHub

assertEqualFloat(a, b, precision=1e-05)[source][source]

Checks that abs(a-b) < precision.

source on GitHub

assertEqualNumber(d1, d2, **kwargs)[source][source]

Checks that two numbers are equal.

source on GitHub

assertExists(name)[source][source]

Checks that name exists.

source on GitHub

assertGreater(x, y, strict=False)[source][source]

Checks that x >= y.

source on GitHub

assertLesser(x, y, strict=False)[source][source]

Checks that x <= y.

source on GitHub

assertNotEmpty(x)[source][source]

Checks that x is not empty.

source on GitHub

assertNotEndsWith(sub, whole)[source][source]

Checks that string sub does not end with whole.

source on GitHub

assertNotEqual(a, b)[source][source]

Checks that a != b.

source on GitHub

assertNotEqualArray(d1, d2, **kwargs)[source][source]

Checks that two arrays are equal. Relies on numpy.testing.assert_almost_equal.html.

source on GitHub

assertNotEqualDataFrame(d1, d2, **kwargs)[source][source]

Checks that two dataframes are different. Calls pandas.testing.assert_frame_equal.

source on GitHub

assertNotExists(name)[source][source]

Checks that name does not exist.

source on GitHub

assertNotStartsWith(sub, whole)[source][source]

Checks that string sub does not start with whole.

source on GitHub

assertRaise(fct, exc=None, msg=None)[source][source]

Checks that function fct with no parameter raises an exception of a given type.

Parameters
  • fct – function to test (no parameter)

  • exc – exception type to catch (None for all)

  • msg – error message to check (None for no message to check)

source on GitHub

assertStartsWith(sub, whole)[source][source]

Checks that string sub starts with whole.

source on GitHub

capture(fct)[source][source]

Runs a function and capture standard otuput and error.

source on GitHub

fLOG(*args, **kwargs)[source][source]

Prints out some information. fLOG.

source on GitHub

profile(fct, sort='cumulative', rootrem=None)[source][source]

Profiles the execution of a function.

Parameters
  • fct – function to profile

  • sort – see sort_stats

  • rootrem – root to remove in filenames

Returns

statistics text dump

source on GitHub

read_file(filename, mode='r', encoding='utf-8')[source][source]

Returns the content of a file.

Parameters
  • filename – filename

  • encoding – encoding

  • mode – reading mode

Returns

content

source on GitHub

setUp()[source][source]

Filters out FutureWarning, PendingDeprecationWarning.

source on GitHub

tearDown()[source][source]

Stops filtering out FutureWarning, PendingDeprecationWarning.

source on GitHub

write_file(filename, content, mode='w', encoding='utf-8')[source][source]

Writes the content of a file.

Parameters
  • filename – filename

  • content – content to write

  • encoding – encoding

  • mode – reading mode

Returns

content

source on GitHub

pyquickhelper.pycode.unittestclass.skipif_appveyor(msg)[source][source]

Skips a unit test if it runs on appveyor.

source on GitHub

pyquickhelper.pycode.unittestclass.skipif_azure(msg)[source][source]

Skips a unit test if it runs on azure pipeline.

source on GitHub

pyquickhelper.pycode.unittestclass.skipif_azure_linux(msg)[source][source]

Skips a unit test if it runs on azure pipeline on linux.

source on GitHub

pyquickhelper.pycode.unittestclass.skipif_azure_macosx(msg)[source][source]

Skips a unit test if it runs on azure pipeline on linux.

source on GitHub

pyquickhelper.pycode.unittestclass.skipif_circleci(msg)[source][source]

Skips a unit test if it runs on circleci.

source on GitHub

pyquickhelper.pycode.unittestclass.skipif_linux(msg)[source][source]

Skips a unit test if it runs on linux.

New in version 1.7.

source on GitHub

pyquickhelper.pycode.unittestclass.skipif_travis(msg)[source][source]

Skips a unit test if it runs on travis.

source on GitHub

pyquickhelper.pycode.unittestclass.skipif_vless(version, msg)[source][source]

Skips a unit test if the version is stricly below version (tuple).

New in version 1.7.

source on GitHub

pyquickhelper.pycode.unittestclass.unittest_require_at_least(mod, version, msg='')[source][source]

Skips a unit test if the version of one module is not at least the provided version.

Parameters
  • mod – module (the module must have an attribute __version__)

  • version – expected version or more recent

  • msg – message

New in version 1.9.

source on GitHub