def test_pymake_simple(): with cd('src/tests/playground'): assert str(pymake.echo1) == "hello world\n" _pymake('echo1') # Run it again, for coverage assert str(pymake.echo2) == "hello world\n" _pymake('echo2') # Run it again, for coverage assert str(pymake.echo3) == "hello world\nhello world\n" _pymake('echo3') # Run it again, for coverage
def test_pymake_args(): with cd('src/tests/playground'): assert str(pymake.echo1('msg1=Bill')) == "hello Bill\n" _pymake('echo1', "msg1=Bill") # Run it again, for coverage assert str(pymake.echo2('msg2=Mary')) == "hello Mary\n" _pymake('echo2', "msg2=Mary") # Run it again, for coverage assert (str(pymake.echo3('msg1=Bill', 'msg2=Mary')) == "hello Bill\nhello Mary\n") _pymake('echo3', "msg1=Bill", "msg2=Mary")
def test_source(): # Simple with cd('src/tests/playground'): with source('env'): assert os.environ['FOO___'] == "foo" assert 'BAR___' not in os.environ assert 'FOO___' not in os.environ source('env') assert os.environ['FOO___'] == "foo" assert 'BAR___' not in os.environ del os.environ['FOO___'] assert 'FOO___' not in os.environ # Recursive with cd('src/tests/playground/envdir'): with source('env', recursive=True): assert os.environ['FOO___'] == "foo" assert os.environ['BAR___'] == "bar" assert 'FOO___' not in os.environ assert 'BAR___' not in os.environ source('env', recursive=True) assert os.environ['FOO___'] == "foo" assert os.environ['BAR___'] == "bar" del os.environ['FOO___'] assert 'FOO___' not in os.environ del os.environ['BAR___'] assert 'BAR___' not in os.environ # Bad file with cd('src/tests/playground'): prev = dict(os.environ) source('bad_env') assert prev == dict(os.environ) with pytest.raises(PipePyError): source('bad_env', quiet=False) # Preserves further edits with cd('src/tests/playground'): with source('env'): export(FOO___="FOO") assert os.environ['FOO___'] == "FOO"
def test_cd(): original_pwd = pwd() cd('src') assert pwd() == original_pwd + "/src" cd('..') assert pwd() == original_pwd with cd('src'): assert pwd() == original_pwd + "/src" assert pwd() == original_pwd cd(original_pwd)
def test_pymake_dependencies(): with cd('src/tests/playground'): assert str(pymake.echo4('msg1=Bill')) == "hello Bill\nhello world\n" _pymake('echo4', "msg1=Bill")
def test_pymake_default_target(): with cd('src/tests/playground'): assert str(pymake) == "hello world\n" _pymake() assert str(pymake('msg1=Bill')) == "hello Bill\n" _pymake("msg1=Bill")