mcstasscript.tests.test_ComponentReader.TestComponentReader

mcstasscript.tests.test_ComponentReader.TestComponentReader

class mcstasscript.tests.test_ComponentReader.TestComponentReader(methodName='runTest')

Testing the ComponenReader class. As this class reads information from McStas, a dummy McStas install is made in the test folder to avoid the test results changing with updates of McStas.

__init__(methodName='runTest')

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.

Methods

__init__([methodName])

Create an instance of the class that will use the named test method when executed.

addClassCleanup(function, /, *args, **kwargs)

Same as addCleanup, except the cleanup items are called even if setUpClass fails (unlike tearDownClass).

addCleanup(function, /, *args, **kwargs)

Add a function, with arguments, to be called when the test is completed.

addTypeEqualityFunc(typeobj, function)

Add a type specific assertEqual style function to compare a type.

assertAlmostEqual(first, second[, places, ...])

Fail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is more than the given delta.

assertAlmostEquals(**kwargs)

assertCountEqual(first, second[, msg])

Asserts that two iterables have the same elements, the same number of times, without regard to order.

assertDictContainsSubset(subset, dictionary)

Checks whether dictionary is a superset of subset.

assertDictEqual(d1, d2[, msg])

assertEqual(first, second[, msg])

Fail if the two objects are unequal as determined by the '==' operator.

assertEquals(**kwargs)

assertFalse(expr[, msg])

Check that the expression is false.

assertGreater(a, b[, msg])

Just like self.assertTrue(a > b), but with a nicer default message.

assertGreaterEqual(a, b[, msg])

Just like self.assertTrue(a >= b), but with a nicer default message.

assertIn(member, container[, msg])

Just like self.assertTrue(a in b), but with a nicer default message.

assertIs(expr1, expr2[, msg])

Just like self.assertTrue(a is b), but with a nicer default message.

assertIsInstance(obj, cls[, msg])

Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.

assertIsNone(obj[, msg])

Same as self.assertTrue(obj is None), with a nicer default message.

assertIsNot(expr1, expr2[, msg])

Just like self.assertTrue(a is not b), but with a nicer default message.

assertIsNotNone(obj[, msg])

Included for symmetry with assertIsNone.

assertLess(a, b[, msg])

Just like self.assertTrue(a < b), but with a nicer default message.

assertLessEqual(a, b[, msg])

Just like self.assertTrue(a <= b), but with a nicer default message.

assertListEqual(list1, list2[, msg])

A list-specific equality assertion.

assertLogs([logger, level])

Fail unless a log message of level level or higher is emitted on logger_name or its children.

assertMultiLineEqual(first, second[, msg])

Assert that two multi-line strings are equal.

assertNotAlmostEqual(first, second[, ...])

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is less than the given delta.

assertNotAlmostEquals(**kwargs)

assertNotEqual(first, second[, msg])

Fail if the two objects are equal as determined by the '!=' operator.

assertNotEquals(**kwargs)

assertNotIn(member, container[, msg])

Just like self.assertTrue(a not in b), but with a nicer default message.

assertNotIsInstance(obj, cls[, msg])

Included for symmetry with assertIsInstance.

assertNotRegex(text, unexpected_regex[, msg])

Fail the test if the text matches the regular expression.

assertNotRegexpMatches(**kwargs)

assertRaises(expected_exception, *args, **kwargs)

Fail unless an exception of class expected_exception is raised by the callable when invoked with specified positional and keyword arguments.

assertRaisesRegex(expected_exception, ...)

Asserts that the message in a raised exception matches a regex.

assertRaisesRegexp(**kwargs)

assertRegex(text, expected_regex[, msg])

Fail the test unless the text matches the regular expression.

assertRegexpMatches(**kwargs)

assertSequenceEqual(seq1, seq2[, msg, seq_type])

An equality assertion for ordered sequences (like lists and tuples).

assertSetEqual(set1, set2[, msg])

A set-specific equality assertion.

assertTrue(expr[, msg])

Check that the expression is true.

assertTupleEqual(tuple1, tuple2[, msg])

A tuple-specific equality assertion.

assertWarns(expected_warning, *args, **kwargs)

Fail unless a warning of class warnClass is triggered by the callable when invoked with specified positional and keyword arguments.

assertWarnsRegex(expected_warning, ...)

Asserts that the message in a triggered warning matches a regexp.

assert_(**kwargs)

countTestCases()

debug()

Run the test without collecting errors in a TestResult

defaultTestResult()

doClassCleanups()

Execute all class cleanup functions.

doCleanups()

Execute all cleanup functions.

fail([msg])

Fail immediately, with the given message.

failIf(**kwargs)

failIfAlmostEqual(**kwargs)

failIfEqual(**kwargs)

failUnless(**kwargs)

failUnlessAlmostEqual(**kwargs)

failUnlessEqual(**kwargs)

failUnlessRaises(**kwargs)

id()

run([result])

setUp()

Hook method for setting up the test fixture before exercising it.

setUpClass()

Hook method for setting up class fixture before running tests in the class.

shortDescription()

Returns a one-line description of the test, or None if no description has been provided.

skipTest(reason)

Skip this test.

subTest([msg])

Return a context manager that will return the enclosed block of code in a subtest identified by the optional message and keyword parameters.

tearDown()

Hook method for deconstructing the test fixture after testing it.

tearDownClass()

Hook method for deconstructing the class fixture after running all tests in the class.

test_ComponentReader_find_components_categories(...)

Test that ComponentReader initializes component categories correctly

test_ComponentReader_find_components_names(...)

Test that ComponentReader initializes component names correctly

test_ComponentReader_init_categories(mock_stdout)

Test that ComponentReader initializes categories correctly

test_ComponentReader_init_component_paths(...)

Test that ComponentReader stores correct absolute paths to the components found in the McStas installation

test_ComponentReader_init_component_paths_input(...)

Test that ComponentReader stores correct absolute paths to the components found in the McStas installation.

test_ComponentReader_init_filenames(mock_stdout)

Test that ComponentReader initializes component names correctly

test_ComponentReader_init_overwrite_message(...)

Test that ComponentReader reports overwritten components Here using default input path, which is current folder

test_ComponentReader_init_overwrite_message_input(...)

Test that ComponentReader reports overwritten components Here using user defined input path, a directory in tests

test_ComponentReader_load_all_components(...)

Load all components in the dummy install, but only one has any content.

test_ComponentReader_read_component_category(...)

Check that the correct category is returned.

test_ComponentReader_read_component_int(...)

Test that a integer parameter is read correctly when reading an component file.

test_ComponentReader_read_component_required(...)

Test that a required parameter is read correctly when reading a component file.

test_ComponentReader_read_component_standard(...)

Test that a normal parameter is read correctly when reading a component file.

test_ComponentReader_read_component_string(...)

Test that a string parameter is read correctly when reading a component file.

test_ComponentReader_read_name_error(mock_stdout)

read_name should throw an error when searching for a component that is not present in the installation.

test_ComponentReader_read_name_success(...)

Read component simply calls read_component_file, but here the output is checked against what is in the dummy file.

test_ComponentReader_show_categories(mock_stdout)

This method prints to console, check it prints the categories in the dummy installation correctly.

test_ComponentReader_show_categories_ordered(...)

Check that the print to console is ordered as usual.

test_ComponentReader_show_components_short(...)

Here we attempt to show components in the misc category.

Attributes

longMessage

maxDiff

test_ComponentReader_find_components_categories(mock_stdout)

Test that ComponentReader initializes component categories correctly

test_ComponentReader_find_components_names(mock_stdout)

Test that ComponentReader initializes component names correctly

test_ComponentReader_init_categories(mock_stdout)

Test that ComponentReader initializes categories correctly

test_ComponentReader_init_component_paths(mock_stdout)

Test that ComponentReader stores correct absolute paths to the components found in the McStas installation

test_ComponentReader_init_component_paths_input(mock_stdout)

Test that ComponentReader stores correct absolute paths to the components found in the McStas installation. This version uses custom input_path

test_ComponentReader_init_filenames(mock_stdout)

Test that ComponentReader initializes component names correctly

test_ComponentReader_init_overwrite_message(mock_stdout)

Test that ComponentReader reports overwritten components Here using default input path, which is current folder

test_ComponentReader_init_overwrite_message_input(mock_stdout)

Test that ComponentReader reports overwritten components Here using user defined input path, a directory in tests

test_ComponentReader_load_all_components(mock_stdout)

Load all components in the dummy install, but only one has any content. The method is currently not necessary, as components are now loaded individually when needed.

test_ComponentReader_read_component_category(mock_stdout)

Check that the correct category is returned.

Can’t run this test with overwritten component test_for_reading. read_component will report tests as category, but this is overwritten by read_name in normal use.

test_ComponentReader_read_component_int(mock_stdout)

Test that a integer parameter is read correctly when reading an component file. Has default, is int type (comments and unit checked already)

test_ComponentReader_read_component_required(mock_stdout)

Test that a required parameter is read correctly when reading a component file. Has no default, is double type, has no comment, has no unit

test_ComponentReader_read_component_standard(mock_stdout)

Test that a normal parameter is read correctly when reading a component file. Has default, is double type, has comment, has unit

test_ComponentReader_read_component_string(mock_stdout)

Test that a string parameter is read correctly when reading a component file. Has no default, is string type (comments and unit checked already)

test_ComponentReader_read_name_error(mock_stdout)

read_name should throw an error when searching for a component that is not present in the installation.

test_ComponentReader_read_name_success(mock_stdout)

Read component simply calls read_component_file, but here the output is checked against what is in the dummy file.

test_ComponentReader_show_categories(mock_stdout)

This method prints to console, check it prints the categories in the dummy installation correctly.

test_ComponentReader_show_categories_ordered(mock_stdout)

Check that the print to console is ordered as usual. This test may be implementation dependent as python dictionaries are not ordered.

test_ComponentReader_show_components_short(mock_stdout)

Here we attempt to show components in the misc category. In the dummy install, there are two components in this folder, but one of these is overwritten by the version in the current work directory.