Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove slow test marker #300

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")