-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed test data file locations (#76)
* Created test fixture pyogg_config. * Fixed location of test data files. They now are always stored in `tests/out` irrespective of the current working directory. * Added signed attribute to FlacFile
- Loading branch information
1 parent
c78487e
commit 3783343
Showing
14 changed files
with
292 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import pathlib | ||
|
||
# Definition of class returned by PyTest fixture 'pyogg_config'. | ||
class Config: | ||
def __init__(self): | ||
self.rootdir: pathlib.Path | ||
self.outdir: pathlib.Path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import shutil | ||
from typing import Any | ||
|
||
import pytest | ||
|
||
from config import Config | ||
|
||
|
||
_config = Config() | ||
|
||
|
||
# FIXME: Mypy: What is the correct type for 'config'? It is of type | ||
# _pytest.config.Config (see | ||
# https://docs.pytest.org/en/stable/_modules/_pytest/hookspec.html#pytest_configure) | ||
# but this isn't part of the public API. Using 'Any' as a | ||
# placeholder. | ||
def pytest_configure(config: Any) -> None: | ||
# Create an object to store the directories | ||
|
||
_config.rootdir = config.rootdir | ||
_config.outdir = config.rootdir / "tests/out" | ||
|
||
# If the previous output directory exists, delete it | ||
out_previous = config.rootdir / "tests/out_previous" | ||
if out_previous.exists(): | ||
try: | ||
shutil.rmtree(out_previous) | ||
except Exception as e: | ||
raise Exception( | ||
"Failed to remove previous output directory. "+ | ||
"You will need to manually delete the directory "+ | ||
f"'{out_previous}': "+str(e) | ||
) | ||
|
||
# If the output directory already exists, rename it | ||
if _config.outdir.exists(): | ||
_config.outdir.rename(config.rootdir / "tests/out_previous") | ||
|
||
# Create the output directory | ||
_config.outdir.mkdir() | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def pyogg_config() -> Config: | ||
return _config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.