Skip to content

Commit

Permalink
Fix Pytest deprecation errors (#600)
Browse files Browse the repository at this point in the history
* fix Pytest deprecation of directly calling fixtures
* shuffle_characteristic should just be a function
  • Loading branch information
StanczakDominik committed Jan 22, 2019
1 parent c932b10 commit 6d17295
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions plasmapy/classes/tests/test_Species.py
Expand Up @@ -98,7 +98,7 @@ def sine(t, amplitude, omega, phase, mean):
# # s.plot_trajectories()


def test_particle_exb_drift():
def test_particle_exb_drift(uniform_magnetic_field):
r"""
Tests the particle stepper for a field with magnetic field in the Z
direction, electric field in the y direction. This should produce a
Expand All @@ -108,7 +108,7 @@ def test_particle_exb_drift():
which is independent of ion charge.
"""
test_plasma = uniform_magnetic_field()
test_plasma = uniform_magnetic_field
test_plasma.electric_field[1] = 1 * u.V / u.m
expected_drift_velocity = -(test_plasma.electric_field_strength /
test_plasma.magnetic_field_strength).mean() \
Expand Down
23 changes: 9 additions & 14 deletions plasmapy/diagnostics/tests/test_langmuir.py
Expand Up @@ -165,7 +165,6 @@ def characteristic_simulated():
return langmuir.Characteristic(bias_simarr, current_simarr)


@pytest.fixture
def shuffle_characteristic(characteristic):
r""""Shuffle a given characteristic"""

Expand Down Expand Up @@ -239,10 +238,10 @@ def test_inplace_unique_bias():
assert isinstance(new_char, langmuir.Characteristic)

@staticmethod
def test_getpadded_limit():
def test_getpadded_limit(characteristic):
r"""Test padding limit on Characteristic instance"""

char = characteristic()
char = characteristic
limits = char.get_padded_limit(0.1)
log_limits = char.get_padded_limit(0.1, log=True)
assert np.allclose(limits.to(u.A).value,
Expand Down Expand Up @@ -277,19 +276,17 @@ def test_negative_area():

@staticmethod
@pytest.mark.parametrize("bimaxwellian", [True, False])
def test_ordering_invariance(bimaxwellian):
def test_ordering_invariance(bimaxwellian, characteristic_simulated):
r"""Test invariance to ordering of the bias and current values"""

sim = characteristic_simulated()

sim_result = langmuir.swept_probe_analysis(
sim,
characteristic_simulated,
1 * u.cm**2,
'Ar-40 1+',
bimaxwellian=bimaxwellian)

sim_result_shuffled = langmuir.swept_probe_analysis(
shuffle_characteristic(sim),
shuffle_characteristic(characteristic_simulated),
1 * u.cm**2,
'Ar-40 1+',
bimaxwellian=bimaxwellian)
Expand All @@ -300,19 +297,17 @@ def test_ordering_invariance(bimaxwellian):
assert (sim_result[key] == sim_result_shuffled[key]).all(), errStr


def test_get_floating_potential_with_return_arg():
def test_get_floating_potential_with_return_arg(characteristic):
r"""Test floating potential and the return argument"""

char = characteristic()
potential, arg = langmuir.get_floating_potential(char, return_arg=True)
potential, arg = langmuir.get_floating_potential(characteristic, return_arg=True)
assert np.allclose((potential.to(u.V).value, arg), (0.12203823, 5))


def test_get_ion_density_OML_without_return_fit():
def test_get_ion_density_OML_without_return_fit(characteristic):
r"""Test ion density without returning the fit value"""

char = characteristic()
density = langmuir.get_ion_density_OML(char, 5000000*u.m**2,
density = langmuir.get_ion_density_OML(characteristic, 5000000*u.m**2,
'p+', return_fit=False)
assert np.isclose(density.value, 385344135.12064785)

Expand Down

0 comments on commit 6d17295

Please sign in to comment.