mcstasscript.tests.test_component.TestComponent

mcstasscript.tests.test_component.TestComponent

class mcstasscript.tests.test_component.TestComponent(methodName='runTest')

Components are the building blocks used to create an instrument in the McStas meta language. They describe spatially seperated parts of the neutron scattering instrument. Here the class component is tested.

__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_Component_basic_init()

Testing basic initialization

test_Component_basic_init_defaults()

Testing basic initialization sets the correct defaults

test_Component_basic_init_set_AT()

Testing set_AT method

test_Component_basic_init_set_AT_Component()

Testing set_AT method using Component object and method

test_Component_basic_init_set_AT_Component_keyword()

Testing set_AT method using Component object and keyword argument

test_Component_basic_init_set_EXTEND()

Testing set_EXTEND method

test_Component_basic_init_set_GROUP()

Testing set_GROUP method

test_Component_basic_init_set_JUMP()

Testing set_JUMP method

test_Component_basic_init_set_RELATIVE()

Testing set_RELATIVE method with string

test_Component_basic_init_set_ROTATED()

Testing set_ROTATED method med relative as string

test_Component_basic_init_set_ROTATED_Component()

Testing set_ROTATED method with relative as Component object

test_Component_basic_init_set_ROTATED_Component_keyword()

Testing setting ROTATION with keyword and Component object input

test_Component_basic_init_set_SPLIT()

Testing set_SPLIT method

test_Component_basic_init_set_WHEN()

Testing WHEN method

test_Component_basic_init_set_comment()

Testing set_comment method

test_Component_basic_new_attribute_error()

The Component class is frozen after initialize in order to prevent the user accidentilly misspelling an attribute name, or at least be able to report an error when they do so.

test_Component_basic_object_ref_init_set_RELATIVE()

Testing set_RELATIVE method with Component object input

test_Component_freeze()

Testing frozen Component cant have new attributes, and that _unfreeze / _freeze works correctly.

test_Component_init_complex_call()

Testing keywords set attributes correctly

test_Component_init_complex_call_relative()

Tests the relative keyword overwrites AT_relative and ROTATED_relative

test_Component_print_long(mock_stdout)

Test print to console on the current state of the Component.

test_Component_print_short_longest_name(...)

Test print_short that prints name, type and location of the Component to the console.

test_Component_print_short_standard(mock_stdout)

Test print_short that prints name, type and location of the Component to the console.

test_Component_show_parameters(mock_stdout)

Test print_short that prints name, type and location of the Component to the console.

test_Component_show_parameters_simple(...)

Test print_short that prints name, type and location of the Component to the console.

test_Component_write_Component_required_parameter_error(mock_f)

Test an error occurs if the Component is asked to write to disk without a required parameter.

test_Component_write_to_file_complex(mock_f)

Testing that a Component can be written to file with the expected output.

test_Component_write_to_file_complex_SPLIT_string(mock_f)

Testing that a Component can be written to file with the expected output.

test_Component_write_to_file_include(mock_f)

Testing that a Component can be written to file with the expected output.

test_Component_write_to_file_simple(mock_f)

Testing that a Component can be written to file with the expected output.

test_Component_write_to_file_simple_search(mock_f)

Testing that a Component can be written to file with the expected output.

test_component_basic_init_set_parameters()

Testing set_parameters method.

test_component_error_check()

Attributes

longMessage

maxDiff

test_Component_basic_init()

Testing basic initialization

test_Component_basic_init_defaults()

Testing basic initialization sets the correct defaults

test_Component_basic_init_set_AT()

Testing set_AT method

test_Component_basic_init_set_AT_Component()

Testing set_AT method using Component object and method

test_Component_basic_init_set_AT_Component_keyword()

Testing set_AT method using Component object and keyword argument

test_Component_basic_init_set_EXTEND()

Testing set_EXTEND method

test_Component_basic_init_set_GROUP()

Testing set_GROUP method

test_Component_basic_init_set_JUMP()

Testing set_JUMP method

test_Component_basic_init_set_RELATIVE()

Testing set_RELATIVE method with string

test_Component_basic_init_set_ROTATED()

Testing set_ROTATED method med relative as string

test_Component_basic_init_set_ROTATED_Component()

Testing set_ROTATED method with relative as Component object

test_Component_basic_init_set_ROTATED_Component_keyword()

Testing setting ROTATION with keyword and Component object input

test_Component_basic_init_set_SPLIT()

Testing set_SPLIT method

test_Component_basic_init_set_WHEN()

Testing WHEN method

test_Component_basic_init_set_comment()

Testing set_comment method

test_Component_basic_new_attribute_error()

The Component class is frozen after initialize in order to prevent the user accidentilly misspelling an attribute name, or at least be able to report an error when they do so.

test_Component_basic_object_ref_init_set_RELATIVE()

Testing set_RELATIVE method with Component object input

test_Component_freeze()

Testing frozen Component cant have new attributes, and that _unfreeze / _freeze works correctly.

test_Component_init_complex_call()

Testing keywords set attributes correctly

test_Component_init_complex_call_relative()

Tests the relative keyword overwrites AT_relative and ROTATED_relative

test_Component_print_long(mock_stdout)

Test print to console on the current state of the Component. Using a mocked stdout to catch the print statements.

test_Component_print_short_longest_name(mock_stdout)

Test print_short that prints name, type and location of the Component to the console. Here with specified longest_name.

test_Component_print_short_standard(mock_stdout)

Test print_short that prints name, type and location of the Component to the console.

test_Component_show_parameters(mock_stdout)

Test print_short that prints name, type and location of the Component to the console. An extra parameter was added. This test also checks for specific formatting.

test_Component_show_parameters_simple(mock_stdout)

Test print_short that prints name, type and location of the Component to the console. No formatting used in simple version.

test_Component_write_Component_required_parameter_error(mock_f)

Test an error occurs if the Component is asked to write to disk without a required parameter.

test_Component_write_to_file_complex(mock_f)

Testing that a Component can be written to file with the expected output. Here with complex input.

test_Component_write_to_file_complex_SPLIT_string(mock_f)

Testing that a Component can be written to file with the expected output. Here with complex input, and a string as given for split.

test_Component_write_to_file_include(mock_f)

Testing that a Component can be written to file with the expected output. Here with simple input.

test_Component_write_to_file_simple(mock_f)

Testing that a Component can be written to file with the expected output. Here with simple input.

Testing that a Component can be written to file with the expected output. Here with simple input and search.

test_component_basic_init_set_parameters()

Testing set_parameters method. Need to set some attribute parameters manually to test this.