owmeta_pytest_plugin package¶
-
class
owmeta_pytest_plugin.BundleData(id, version, source_directory, remote)¶ Bases:
tupleCreate new instance of BundleData(id, version, source_directory, remote)
-
property
id¶ Alias for field number 0
-
property
remote¶ Alias for field number 3
-
property
source_directory¶ Alias for field number 2
-
property
version¶ Alias for field number 1
-
property
-
class
owmeta_pytest_plugin.Data[source]¶ Bases:
objectObject returned by
shell_helperandowm_project(and related fixtures). Additional standard attributes may be added by the various fixtures.- Attributes
-
make_module(module)[source]¶ Create a module directory under
testdir. Each of the intermediate directories (if there are any) will also be usable as modules (i.e., they’ll have __init__.py files in them).
-
sh(*command, **kwargs)[source]¶ Execute commands with the working directory set to
testdir, theHOMEenvironment variable set totest_homedir, and withtestdirprepended toPYTHONPATH.- Parameters
- *command
listofstr Command or commands to execute
- **kwargs
dict Additional arguments to
subprocess.check_output
- *command
- Returns
strorlistofstrOutput of the given command. See
subprocess.check_outputfor details on return values and how they are affected by arguments to that function.
-
owmeta_pytest_plugin.bundle(request)¶ A fixture for bundles.
Example usage:
@bundles([('example/aBundle', 1), ('_orphans/aBundle', 2), ('phoenix/aBundle', 3),]) def test_bundle_with_renames(bundle): # do something with versions of aBundle
-
owmeta_pytest_plugin.bundle_fixture_helper(bundle_id, version=None)[source]¶ Creates test fixtures for testing with pre-made bundles. These may be for testing against older versions of bundles maintained within the project or for creating a “test fake” of a bundle dependency to test integration short of fetching the full dependency.
The source directory for the bundles follows exactly the same structure as the bundle cache directory in
~/.owmeta/bundles. The location for the directory comes from theTEST_BUNDLES_DIRECTORYenvironment variable and defaults tobundlesin the current working directory if that variable is unset.If
versionis omitted, then the version numbers will come from parameters, typically provided by pytest.mark.paremetrize.bundlesandbundle_versionshelp with this.For example:
my_bundle = pytest.fixture(bundle_fixture_helper('example/my_bundle')) @bundle_versions('my_bundle', list(range(1, 5))) def test_my_bundle(my_bundle): # do something with my_bundle
- Parameters
- Returns
functionA function to pass to
pytest.fixture
-
owmeta_pytest_plugin.bundle_versions(fixture_name, versions)[source]¶ Parameterize a bundle fixture with versions of the bundle to test against
-
owmeta_pytest_plugin.bundles(versions)[source]¶ Parameterize the
bundlefixture with bundle IDs and versions to test against
-
owmeta_pytest_plugin.owm_project(request)[source]¶ Returns a
shell_helperfixture but with a .owm project directory in the test directory. The helper also gets new methods:owm(**kwargs): Creates and returns anOWMwith itsowmdirat the test .owm directoryfetch(bundle_data): Fetches a bundle into the test home directory.bundle_datalikely comes from a test fixture created withbundle_fixture_helper
-
owmeta_pytest_plugin.owm_project_with_customizations(request)[source]¶ Factory for an
owm_projectcontext manager. Accepts acustomizationsargument, the same asshell_helper_with_customizations.
-
owmeta_pytest_plugin.shell_helper(request)[source]¶ Helper for running shell commands from a temporary working directory and home directory. Returns a
Datainstance.
-
owmeta_pytest_plugin.shell_helper_with_customizations(request)[source]¶ Like
shell_helper, but returns a context manager instead which accepts acustomizationsargument, a string that will be written as the contents ofsitecustomize.pyto be picked up for any executions ofsh