| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import subprocess |
| import sys |
| from os import path |
|
|
| import pytest |
|
|
|
|
| class TestHydraRunner: |
| @pytest.mark.integration |
| def test_no_config(self): |
| """"Test app without config - fields missing causes error. |
| """ |
| |
| call = "python tests/hydra/my_app.py" |
|
|
| with pytest.raises(subprocess.CalledProcessError): |
| |
| subprocess.check_call(call, shell=True, stdout=sys.stdout, stderr=sys.stdout) |
|
|
| @pytest.mark.integration |
| def test_config1(self): |
| """"Test injection of valid config1. |
| """ |
| |
| call = "python tests/hydra/my_app.py --config-name config1.yaml" |
|
|
| |
| subprocess.check_call(call, shell=True, stdout=sys.stdout, stderr=sys.stdout) |
|
|
| |
| assert not path.exists(f".hydra") |
| |
| assert not path.exists(f"my_app.log") |
|
|
| @pytest.mark.integration |
| def test_config1_invalid(self): |
| """"Test injection of invalid config1. |
| """ |
| |
| call = "python tests/hydra/my_app.py --config-name config1_invalid.yaml" |
|
|
| with pytest.raises(subprocess.CalledProcessError): |
| |
| subprocess.check_call(call, shell=True, stdout=sys.stdout, stderr=sys.stdout) |
|
|
| @pytest.mark.integration |
| def test_config2(self): |
| """"Test injection of valid config2 from a different folder. |
| """ |
| |
| call = "python tests/hydra/my_app.py --config-path config_subdir --config-name config2.yaml" |
|
|
| |
| subprocess.check_call(call, shell=True, stdout=sys.stdout, stderr=sys.stdout) |
|
|
| |
| assert not path.exists(f".hydra") |
| |
| assert not path.exists(f"my_app.log") |
|
|
| @pytest.mark.integration |
| def test_config2_invalid(self): |
| """"Test injection of invalid config2 from a different folder. |
| """ |
| |
| call = "python tests/hydra/my_app.py --config-path config_subdir --config-name config2_invalid.yaml" |
|
|
| with pytest.raises(subprocess.CalledProcessError): |
| |
| subprocess.check_call(call, shell=True, stdout=sys.stdout, stderr=sys.stdout) |
|
|
| @pytest.mark.integration |
| def test_config2_filepath_schema(self): |
| """"Test injection of valid config2 - using namepath with schema is prohibited. |
| """ |
| |
| call = "python tests/hydra/my_app.py --config-name config_subdir/config2_invalid.yaml" |
|
|
| with pytest.raises(subprocess.CalledProcessError): |
| |
| subprocess.check_call(call, shell=True, stdout=sys.stdout, stderr=sys.stdout) |
|
|