BasicTools.Helpers.Tests module

Testing infrastructure for BasicTools extra modules

BasicTools.Helpers.Tests.CheckIfAllThePresentFilesAreTested(extraToolsBoxes, testedFiles)[source]
BasicTools.Helpers.Tests.CheckIntegrity()[source]
BasicTools.Helpers.Tests.GetUniqueTempFile(suffix: str = '', prefix: str = 'tmp') Tuple[int, str][source]

Create a unique temporary file on the temp directory

Parameters:
  • suffix (str, optional) – If ‘suffix’ is not None, the file name will end with that suffix, otherwise there will be no suffix., by default “”

  • prefix (str, optional) – If ‘prefix’ is not None, the file name will begin with that prefix, otherwise a default prefix is used., by default ‘tmp’

Returns:

please read the doc of module tempfile.mkstemp

Return type:

Tuple[int,str]

BasicTools.Helpers.Tests.RunListOfCheckIntegrities(toTest: List[Callable[[bool], str]], GUI: bool = False) str[source]
Execute all the functions in the list. Stop at the first error.

the functions must return “ok”, “skip” to be treated as successful function

Parameters:
  • toTest (List[Callable[[bool],str] ]) – a list of functions

  • GUI (bool, optional) – bool argument passed to every function , by default False

Returns:

“ok” if all functions are executed correctly (the return of every function is “ok”) “error…” at the first error encountered

Return type:

str

BasicTools.Helpers.Tests.RunTests() int[source]

Base function to run all tests, all the option are captured from the command line arguments.

Returns:

return the number of failed tests

Return type:

int

BasicTools.Helpers.Tests.SkipTest(environnementVariableName: str) bool[source]

chef if a environnement variable is present to help the user to skip test

Parameters:

environnementVariableName (str) – the name of a environnement variable

Returns:

true if the variable is present false if absent

Return type:

bool

BasicTools.Helpers.Tests.TestAll(modulesToTreat=['ALL'], modulesToSkip=[], fullOutput=False, stopAtFirstError=False, extraToolsBoxes=None, dryRun=False, profiling=False, coverage=None, typing=False)[source]
class BasicTools.Helpers.Tests.TestTempDir[source]

Bases: object

Class to generate and to destroy a temporary directory

classmethod DeleteTempPath()[source]
classmethod GetTempPath(onRam=None)[source]
classmethod OpenTempFolder()[source]
classmethod SetTempPath(path, create=True)[source]
createdOnRam = False
path = None
prefix = 'BasicTools_Test_Directory_'
BasicTools.Helpers.Tests.WriteTempFile(filename: str, content: str | None = None, mode: str = 'w') str[source]

Create and fill a temporary file on the temporary folder

Parameters:
  • filename (str) – the name of the file to be created

  • content (str, optional) – the content of the file, by default None

  • mode (str, optional) – read python “open” function documentation for more detail, by default “w”

Returns:

the name of the filename (with the path attached)

Return type:

str

Raises:

Exception – if error during the file creation