Package openmdao.test

This package contains classes and modules that are used to test openmdao.

cluster.py

Routines to support testing with cluster allocation.

openmdao.test.cluster.init_cluster(encrypted=True, clean_dir=True, allow_shell=False)[source]

If not already done, initializes the ResourceAllocationManager and adds a cluster using encrypted or unencrypted communication. Returns the name of the configured cluster.

openmdao.test.cluster.local_ssh_available()[source]

Return True if this user has an authorized key for this machine.

early_report.py

class openmdao.test.early_report.BroadcastStream(*streams)[source]

Bases: object

Sends stream output to multiple streams.

close()[source]
flush()[source]
write(*arg)[source]
writeln(*arg)[source]
class openmdao.test.early_report.EarlyTestInfo[source]

Bases: nose.plugins.base.Plugin

This plugin writes test info (failures, run time) to a file as the tests are running instead of waiting until the end to report anything. Run nose with the option --with-early to activate it.

addError(test, err, capt=None)[source]
addFailure(test, err, capt=None, tb_info=None)[source]
addSkip(test, *args, **kwargs)[source]
addSuccess(test, capt=None)[source]
configure(options, config)[source]

Configures the plugin.

finalize(result)[source]
formatErr(err)[source]
options(parser, env)[source]

Sets additional command line options.

report(stream)[source]

Report the test failures.

setOutputStream(stream)[source]
startContext(ctx)[source]
startTest(test)[source]
stopContext(ctx)[source]
stopTest(test)[source]
name = 'early'
score = 1001
class openmdao.test.early_report.TestInfo(test)[source]

Bases: object

end()[source]

execcomp.py

ExecComp is a simple component that lets you easily define mathematical expressions.

class openmdao.test.execcomp.ExecComp(exprs=(), sleep=0, trace=False)[source]

Bases: openmdao.main.component.Component

Given a list of assignment statements, this component creates input and output I/O traits at construction time. All variables appearing on the left-hand side of the assignments are outputs, and the rest are inputs. All variables are assumed to be of type Float.

exprs: list of strings

sleep: float
Time (in seconds) to sleep during execute.
execute()[source]

ExecComp execute function

class openmdao.test.execcomp.ExecCompWithDerivatives(exprs=(), derivatives=(), sleep=0, dsleep=0)[source]

Bases: openmdao.main.component.Component

Works as ExecComp, except derivatives can also be defined.

Given a list of assignment statements, this component creates input and output I/O traits at construction time. All variables appearing on the left-hand side of the assignments are outputs, and the rest are inputs. All variables are assumed to be of type Float.

execute()[source]

ExecCompWithDerivatives execute function

list_deriv_vars()[source]

Return the full Jacobian

provideJ()[source]

Calculate the Jacobian using our derivative expressions.

mpiunittest.py

A simple unit testing framework for MPI programs.

class openmdao.test.mpiunittest.MPIContext[source]

Bases: object

Supports using the ‘with’ statement when executing code in multiple MPI processes so that if any of the blocks raise an exception, all processes sharing that communicator will fail.

class openmdao.test.mpiunittest.MPITestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

A base class for all TestCases that are intended to run under MPI.

collective_assertAlmostEqual(*args, **kwargs)
collective_assertAlmostEquals(*args, **kwargs)
collective_assertDictContainsSubset(*args, **kwargs)
collective_assertDictEqual(*args, **kwargs)
collective_assertEqual(*args, **kwargs)
collective_assertEquals(*args, **kwargs)
collective_assertFalse(*args, **kwargs)
collective_assertGreater(*args, **kwargs)
collective_assertGreaterEqual(*args, **kwargs)
collective_assertIn(*args, **kwargs)
collective_assertIs(*args, **kwargs)
collective_assertIsInstance(*args, **kwargs)
collective_assertIsNone(*args, **kwargs)
collective_assertIsNot(*args, **kwargs)
collective_assertIsNotNone(*args, **kwargs)
collective_assertItemsEqual(*args, **kwargs)
collective_assertLess(*args, **kwargs)
collective_assertLessEqual(*args, **kwargs)
collective_assertListEqual(*args, **kwargs)
collective_assertMultiLineEqual(*args, **kwargs)
collective_assertNotAlmostEqual(*args, **kwargs)
collective_assertNotAlmostEquals(*args, **kwargs)
collective_assertNotEqual(*args, **kwargs)
collective_assertNotEquals(*args, **kwargs)
collective_assertNotIn(*args, **kwargs)
collective_assertNotIsInstance(*args, **kwargs)
collective_assertNotRegexpMatches(*args, **kwargs)
collective_assertRaises(*args, **kwargs)
collective_assertRaisesRegexp(*args, **kwargs)
collective_assertRegexpMatches(*args, **kwargs)
collective_assertSequenceEqual(*args, **kwargs)
collective_assertSetEqual(*args, **kwargs)
collective_assertTrue(*args, **kwargs)
collective_assertTupleEqual(*args, **kwargs)
collective_assert_(*args, **kwargs)
collective_fail(*args, **kwargs)
run(result=None)[source]
class openmdao.test.mpiunittest.MPITestCaseMeta(name, bases, dct)[source]

Bases: type

A metaclass to wrap all of the test methods to act appropriately when run serially vs. under mpi. Also creates collective versions of all of the ‘assert*’ methods used for testing.

openmdao.test.mpiunittest.collective_assert_rel_error(self, *args, **kwargs)
openmdao.test.mpiunittest.mpi_fail_if_any(f)[source]

In order to keep MPI tests from hanging when a test fails in one process and succeeds in another, perform an allgather to check for any failures in any of the processes running the test, and fail if any of them fail.

openmdao.test.mpiunittest.wrapper(f)[source]

nosetimer.py

This plugin provides test timings to identify which tests might be
taking the most time. From this information, it might be useful to couple
individual tests' nose's `--with-profile` option to profile problematic
tests.

This plugin is heavily influenced by nose's `xunit` plugin.

Add this command to the way you execute nose::

    --with-test-timer

After all tests are executed, they will be sorted in ascending order.

(c) 2011 - Mahmoud Abdelkader (http://github.com/mahmoudimus)

LICENSE:
            DO WHAT THE !#$% YOU WANT TO PUBLIC LICENSE
                    Version 2, December 2004

 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> (slightly modified)

 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.

            DO WHAT THE !#$% YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE !#$% YOU WANT TO.
class openmdao.test.nosetimer.TestTimer[source]

Bases: nose.plugins.base.Plugin

This plugin provides test timings.

addError(test, err, capt=None)[source]
addFailure(test, err, capt=None, tb_info=None)[source]
addSuccess(test, capt=None)[source]
configure(options, config)[source]

Configures the test timer plugin.

options(parser, env)[source]

Sets additional command line options.

report(stream)[source]

Report the test times.

startTest(test)[source]

Initializes a timer before starting a test.

name = 'test-timer'
score = 1

rosen_suzuki.py

Model based on CONMIN test.

class openmdao.test.rosen_suzuki.NestedSimulation[source]

Bases: openmdao.main.assembly.Assembly

configure()[source]
class openmdao.test.rosen_suzuki.OptRosenSuzukiComponent[source]

Bases: openmdao.main.component.Component

Array x
  • default: ‘[]’
  • iotype: ‘in’
  • low: -10
  • high: 99
  • comparison_mode: 1
  • vartypename: ‘Array’
  • assumed_default: True
Float opt_objective
  • default: ‘0.0’
  • iotype: ‘out’
  • vartypename: ‘Float’
  • assumed_default: True
Float result
  • default: ‘0.0’
  • iotype: ‘out’
  • vartypename: ‘Float’
  • assumed_default: True
configure()[source]
execute()[source]

calculate the new objective value

class openmdao.test.rosen_suzuki.PostProc[source]

Bases: openmdao.main.component.Component

Dummy post-processor.

Float result_in
  • default: ‘0.0’
  • iotype: ‘in’
  • vartypename: ‘Float’
  • assumed_default: True
Float result_out
  • default: ‘0.0’
  • iotype: ‘out’
  • vartypename: ‘Float’
  • assumed_default: True
execute()[source]
class openmdao.test.rosen_suzuki.PreProc[source]

Bases: openmdao.main.component.Component

Dummy pre-processor.

Array x_in
  • default: ‘[ 1. 1. 1. 1.]’
  • iotype: ‘in’
  • low: -10
  • high: 99
  • comparison_mode: 1
  • vartypename: ‘Array’
  • assumed_default: False
Array x_out
  • default: ‘[]’
  • iotype: ‘out’
  • comparison_mode: 1
  • vartypename: ‘Array’
  • assumed_default: True
execute()[source]
class openmdao.test.rosen_suzuki.ScalingPostProc[source]

Bases: openmdao.test.rosen_suzuki.PostProc

Scaling post-processor.

Float scaler
  • default: ‘1.0’
  • iotype: ‘in’
  • vartypename: ‘Float’
  • assumed_default: False
execute()[source]
class openmdao.test.rosen_suzuki.ScalingPreProc[source]

Bases: openmdao.test.rosen_suzuki.PreProc

Scaling pre-processor.

Float scaler
  • default: ‘1.0’
  • iotype: ‘in’
  • vartypename: ‘Float’
  • assumed_default: False
execute()[source]
class openmdao.test.rosen_suzuki.Simulation[source]

Bases: openmdao.main.assembly.Assembly

configure()[source]

TEST

test_execcomp.py

Test of the ExecComp component.

class openmdao.test.test.test_execcomp.execCompTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
test_execcomp()[source]
test_execcomp_derivatives()[source]

testing.py

class openmdao.test.testing.TestFailureSummary[source]

Bases: nose.plugins.base.Plugin

This plugin lists the names of the failed tests. Run nose with the option --with-fail-summary to activate it.

addError(test, err, capt=None)[source]
addFailure(test, err, capt=None, tb_info=None)[source]
addSuccess(test, capt=None)[source]
configure(options, config)[source]

Configures the plugin.

options(parser, env)[source]

Sets additional command line options.

report(stream)[source]

Report the test failures.

startTest(test)[source]
name = 'fail-summary'
score = 1
openmdao.test.testing.filter_config(hostlist, config, options)[source]

Looks for sections in the config file that match the host names specified in options.hosts.

Returns a list of host names that match the given options.

openmdao.test.testing.is_dev_install()[source]
openmdao.test.testing.loadTestsFromModule(self, module, path=None, discovered=False)[source]

Load all tests from module and return a suite containing them. If the module has been discovered and is not test-like, the suite will be empty by default, though plugins may add their own tests.

openmdao.test.testing.read_config(options)[source]

Reads the config file specified in options.cfg.

Returns a tuple of the form (hosts, config), where hosts is the list of host names and config is the ConfigParser object for the config file.

openmdao.test.testing.run_openmdao_suite(argv=None)[source]

This function is exported as a script that is runnable as part of an OpenMDAO virtual environment as openmdao test.

This function wraps nosetests, so any valid nose args should also work here.

OpenMDAO Home

Table Of Contents

Previous topic

Package openmdao.main

Next topic

Package openmdao.units

This Page