Skip to content

Commit

Permalink
Remove slow test marker (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamltyson authored May 20, 2024
1 parent ca58fb1 commit 513ddf3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
28 changes: 14 additions & 14 deletions tests/atlasapi/test_config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,33 @@ def test_config_creation(conf_path):
assert val == str(config.TEMPLATE_CONF_DICT[sectname][k])


# Ugly test zone: here we use the terminal commands, which edit the config
# file in the brainglobe_atlasapi repo from which the tests are being run.
# This is not the cleanest way, the alternative would be to run this test in
# a new env.
@pytest.mark.slow
def test_config_edit():
def test_config_edit(tmp_path):
# Create a CliRunner instance
runner = CliRunner()
result = runner.invoke(cli.bg_cli, ["config", "--show"])

# Assert the command ran successfully
assert result.exit_code == 0
assert result.output == config._print_config() + "\n"

# Read the current config
config_pre = config.read_config()
original_bg_folder = config_pre["default_dirs"]["brainglobe_dir"]

new_atlas_dir = Path(tempfile.mkdtemp())
config.write_config_value("brainglobe_dir", new_atlas_dir)
# Create a temporary directory for the new atlas directory
new_atlas_dir = tmp_path / "new_brainglobe_dir"
new_atlas_dir.mkdir()

# Replace the brainglobe_dir in the config with the temp directory
config.write_config_value("brainglobe_dir", str(new_atlas_dir))
config_post = config.read_config()

# Assert that the config was updated correctly
assert config_post["default_dirs"]["brainglobe_dir"] == str(new_atlas_dir)

# Use new location to download:
# Use new location to download the atlas
atlas = bg_atlas.BrainGlobeAtlas(atlas_name="example_mouse_100um")

assert atlas.root_dir.parent == new_atlas_dir

# Fix the mess:
# Restore the original config value
config.write_config_value("brainglobe_dir", original_bg_folder)

# cleanup:
shutil.rmtree(new_atlas_dir)
9 changes: 0 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,3 @@ def temp_path():
@pytest.fixture(scope="module")
def atlas_path():
return BrainGlobeAtlas("example_mouse_100um").root_dir


def pytest_addoption(parser):
parser.addoption("--runslow", action="store_true", help="run slow tests")


def pytest_runtest_setup(item):
if "slow" in item.keywords and not item.config.getvalue("runslow"):
pytest.skip("need --runslow option to run")

0 comments on commit 513ddf3

Please sign in to comment.