Skip to content

Commit

Permalink
Make tests work locally (#154)
Browse files Browse the repository at this point in the history
Improve changelog.
  • Loading branch information
prisae authored Dec 4, 2020
1 parent 4e7df8c commit 58961a6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
17 changes: 9 additions & 8 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ recent versions


The package discretize went through a major restructuring with many name
changes and consequent deprecations. This version updates ``emg3d`` to be
compatible with ``discretize>=0.6.0`` in the long run. It also means that emg3d
will, from ``emg3d>=0.15.0`` onwards, only work with ``discretize>=0.6.0``.
changes and consequent deprecations (see below for a list of affected
mesh-properties for ``emg3d``). This version updates ``emg3d`` to be compatible
with ``discretize>=0.6.0`` in the long run. It also means that emg3d will, from
``emg3d>=0.15.0`` onwards, only work with ``discretize>=0.6.0``.

Other notable changes:

- Bug fix re storing/loading synthetics
- Moved from Travis CI to GitHub Actions.

The relevant aliases and deprecations for ``emg3d`` are (consult the release
notes of ``discretize`` for all changes):
Expand Down Expand Up @@ -57,11 +63,6 @@ names (right).
- ``vectorCCz`` => ``cell_centers_z``
- ``vol`` => ``cell_volumes``

- Other changes:

- Bug fix re storing/loading synthetics
- Moved from Travis CI to GitHub Actions.


*v0.14.3* : Bug fix
-------------------
Expand Down
31 changes: 21 additions & 10 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest
import numpy as np
from numpy.testing import assert_allclose
from contextlib import suppress, ContextDecorator

import emg3d
from emg3d import cli
Expand All @@ -23,11 +24,24 @@
pass


class disable_numba(ContextDecorator):
"""Context decorator to disable-enable JIT and remove log file."""
def __enter__(self):
os.environ["NUMBA_DISABLE_JIT"] = "1"
return self

def __exit__(self, *exc):
os.environ["NUMBA_DISABLE_JIT"] = "0"
# Clean up
with suppress(FileNotFoundError):
os.remove('emg3d_out.log')
return False


@disable_numba()
@pytest.mark.script_launch_mode('subprocess')
def test_basic(script_runner):

os.environ["NUMBA_DISABLE_JIT"] = "1"

# Test the installed version runs by -h.
ret = script_runner.run('emg3d', '-h')
assert ret.success
Expand All @@ -46,29 +60,26 @@ def test_basic(script_runner):
ret = script_runner.run('python', 'emg3d', '--report')
assert ret.success
# Exclude time to avoid errors.
assert emg3d.utils.Report().__repr__()[115:] in ret.stdout
# Exclude empymod-version (after 475), because if run locally without
# having emg3d installed it will be "unknown" for the __main__ one.
assert emg3d.utils.Report().__repr__()[115:475] in ret.stdout

# Test emg3d/cli/_main_.py by calling the file - I.
ret = script_runner.run('python', 'emg3d/cli/main.py', '--version')
assert ret.success
assert emg3d.utils.__version__ in ret.stdout
assert "emg3d v" in ret.stdout

# Test emg3d/cli/_main_.py by calling the file - II.
ret = script_runner.run('python', 'emg3d/cli/main.py', '--report')
assert ret.success
# Exclude time to avoid errors.
assert emg3d.utils.Report().__repr__()[115:] in ret.stdout
assert emg3d.utils.Report().__repr__()[115:475] in ret.stdout

# Test emg3d/cli/_main_.py by calling the file - III.
ret = script_runner.run('python', 'emg3d/cli/main.py', '-d')
assert not ret.success
assert "CONFIGURATION FILE NOT FOUND" in ret.stderr

os.environ["NUMBA_DISABLE_JIT"] = "0"

# Clean up
os.remove('emg3d_out.log')


class TestParser:

Expand Down

0 comments on commit 58961a6

Please sign in to comment.