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

Rename Python test files to be pytest compatible #1599

Merged
merged 1 commit into from
Jun 9, 2021
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
102 changes: 51 additions & 51 deletions python/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ if WITH_MPI
MDPYTEST=
MPBPYTEST=
else
MDPYTEST=$(TEST_DIR)/material_dispersion.py
MDPYTEST=$(TEST_DIR)/test_material_dispersion.py
if WITH_MPB
MPBPYTEST=$(TEST_DIR)/mpb.py
MPBPYTEST=$(TEST_DIR)/test_mpb.py
else
MPBPYTEST=
endif # WITH_MPB
endif # WITH_MPI

if WITH_MPB
BINARY_GRATING_TEST = $(TEST_DIR)/binary_grating.py
DIFFRACTED_PLANEWAVE_TEST = $(TEST_DIR)/diffracted_planewave.py
DISPERSIVE_EIGENMODE_TEST = $(TEST_DIR)/dispersive_eigenmode.py
KDOM_TEST = $(TEST_DIR)/kdom.py
MODE_COEFFS_TEST = $(TEST_DIR)/mode_coeffs.py
MODE_DECOMPOSITION_TEST = $(TEST_DIR)/mode_decomposition.py
WVG_SRC_TEST = $(TEST_DIR)/wvg_src.py
BINARY_GRATING_TEST = $(TEST_DIR)/test_binary_grating.py
DIFFRACTED_PLANEWAVE_TEST = $(TEST_DIR)/test_diffracted_planewave.py
DISPERSIVE_EIGENMODE_TEST = $(TEST_DIR)/test_dispersive_eigenmode.py
KDOM_TEST = $(TEST_DIR)/test_kdom.py
MODE_COEFFS_TEST = $(TEST_DIR)/test_mode_coeffs.py
MODE_DECOMPOSITION_TEST = $(TEST_DIR)/test_mode_decomposition.py
WVG_SRC_TEST = $(TEST_DIR)/test_wvg_src.py
else
BINARY_GRATING_TEST =
DIFFRACTED_PLANEWAVE_TEST =
Expand All @@ -35,56 +35,56 @@ else
endif

TESTS = \
$(TEST_DIR)/3rd_harm_1d.py \
$(TEST_DIR)/absorber_1d.py \
$(TEST_DIR)/adjoint_solver.py \
$(TEST_DIR)/adjoint_jax.py \
$(TEST_DIR)/antenna_radiation.py \
$(TEST_DIR)/array_metadata.py \
$(TEST_DIR)/bend_flux.py \
$(TEST_DIR)/test_3rd_harm_1d.py \
$(TEST_DIR)/test_absorber_1d.py \
$(TEST_DIR)/test_adjoint_solver.py \
$(TEST_DIR)/test_adjoint_jax.py \
$(TEST_DIR)/test_antenna_radiation.py \
$(TEST_DIR)/test_array_metadata.py \
$(TEST_DIR)/test_bend_flux.py \
$(BINARY_GRATING_TEST) \
$(TEST_DIR)/cavity_arrayslice.py \
$(TEST_DIR)/cavity_farfield.py \
$(TEST_DIR)/chunk_layout.py \
$(TEST_DIR)/chunks.py \
$(TEST_DIR)/cyl_ellipsoid.py \
$(TEST_DIR)/dft_energy.py \
$(TEST_DIR)/dft_fields.py \
$(TEST_DIR)/test_cavity_arrayslice.py \
$(TEST_DIR)/test_cavity_farfield.py \
$(TEST_DIR)/test_chunk_layout.py \
$(TEST_DIR)/test_chunks.py \
$(TEST_DIR)/test_cyl_ellipsoid.py \
$(TEST_DIR)/test_dft_energy.py \
$(TEST_DIR)/test_dft_fields.py \
${DIFFRACTED_PLANEWAVE_TEST} \
${DISPERSIVE_EIGENMODE_TEST} \
$(TEST_DIR)/divide_mpi_processes.py \
$(TEST_DIR)/eigfreq.py \
$(TEST_DIR)/faraday_rotation.py \
$(TEST_DIR)/field_functions.py \
$(TEST_DIR)/force.py \
$(TEST_DIR)/fragment_stats.py \
$(TEST_DIR)/gaussianbeam.py \
$(TEST_DIR)/geom.py \
$(TEST_DIR)/get_point.py \
$(TEST_DIR)/holey_wvg_bands.py \
$(TEST_DIR)/holey_wvg_cavity.py \
$(TEST_DIR)/test_divide_mpi_processes.py \
$(TEST_DIR)/test_eigfreq.py \
$(TEST_DIR)/test_faraday_rotation.py \
$(TEST_DIR)/test_field_functions.py \
$(TEST_DIR)/test_force.py \
$(TEST_DIR)/test_fragment_stats.py \
$(TEST_DIR)/test_gaussianbeam.py \
$(TEST_DIR)/test_geom.py \
$(TEST_DIR)/test_get_point.py \
$(TEST_DIR)/test_holey_wvg_bands.py \
$(TEST_DIR)/test_holey_wvg_cavity.py \
$(KDOM_TEST) \
$(TEST_DIR)/ldos.py \
$(TEST_DIR)/test_ldos.py \
$(MDPYTEST) \
$(TEST_DIR)/material_grid.py \
$(TEST_DIR)/medium_evaluations.py \
$(TEST_DIR)/test_material_grid.py \
$(TEST_DIR)/test_medium_evaluations.py \
$(MPBPYTEST) \
$(MODE_COEFFS_TEST) \
$(MODE_DECOMPOSITION_TEST) \
$(TEST_DIR)/multilevel_atom.py \
$(TEST_DIR)/n2f_periodic.py \
$(TEST_DIR)/oblique_source.py \
$(TEST_DIR)/physical.py \
$(TEST_DIR)/prism.py \
$(TEST_DIR)/pw_source.py \
$(TEST_DIR)/refl_angular.py \
$(TEST_DIR)/ring.py \
$(TEST_DIR)/ring_cyl.py \
$(TEST_DIR)/simulation.py \
$(TEST_DIR)/special_kz.py \
$(TEST_DIR)/source.py \
$(TEST_DIR)/user_defined_material.py \
$(TEST_DIR)/visualization.py \
$(TEST_DIR)/test_multilevel_atom.py \
$(TEST_DIR)/test_n2f_periodic.py \
$(TEST_DIR)/test_oblique_source.py \
$(TEST_DIR)/test_physical.py \
$(TEST_DIR)/test_prism.py \
$(TEST_DIR)/test_pw_source.py \
$(TEST_DIR)/test_refl_angular.py \
$(TEST_DIR)/test_ring.py \
$(TEST_DIR)/test_ring_cyl.py \
$(TEST_DIR)/test_simulation.py \
$(TEST_DIR)/test_special_kz.py \
$(TEST_DIR)/test_source.py \
$(TEST_DIR)/test_user_defined_material.py \
$(TEST_DIR)/test_visualization.py \
$(WVG_SRC_TEST)

if WITH_COVERAGE
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def verify_output_and_slice(self,material,frequency):
self.assertAlmostEqual(n,n_slice, places=4)

# Check to make sure h5 output is working with frequency
filename = os.path.join(self.temp_dir, 'dispersive_eigenmode-eps-000000.00.h5')
filename = os.path.join(self.temp_dir,
sim.get_filename_prefix() + '-eps-000000.00.h5')
mp.output_epsilon(sim,frequency=frequency)
n_h5 = 0
mp.all_wait()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 8 additions & 4 deletions python/tests/simulation.py → python/tests/test_simulation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
import sys
import unittest
import warnings
Expand All @@ -14,7 +15,8 @@

class TestSimulation(unittest.TestCase):

fname = 'simulation-ez-000200.00.h5'
fname_base = re.sub(r'\.py$', '', os.path.split(sys.argv[0])[1])
fname = fname_base + '-ez-000200.00.h5'

def setUp(self):
print("Running {}".format(self._testMethodName))
Expand Down Expand Up @@ -138,7 +140,8 @@ def test_at_time(self):
sim.use_output_directory(self.temp_dir)
sim.run(mp.at_time(100, mp.output_efield_z), until=200)

fname = os.path.join(self.temp_dir, 'simulation-ez-000100.00.h5')
fname = os.path.join(self.temp_dir,
sim.get_filename_prefix() + '-ez-000100.00.h5')
self.assertTrue(os.path.exists(fname))

def test_after_sources_and_time(self):
Expand All @@ -158,7 +161,8 @@ def test_with_prefix(self):
sim.use_output_directory(self.temp_dir)
sim.run(mp.with_prefix('test_prefix-', mp.at_end(mp.output_efield_z)), until=200)

fname = os.path.join(self.temp_dir, 'test_prefix-simulation-ez-000200.00.h5')
fname = os.path.join(self.temp_dir, 'test_prefix-' + sim.get_filename_prefix() +
'-ez-000200.00.h5')
self.assertTrue(os.path.exists(fname))

def test_extra_materials(self):
Expand Down Expand Up @@ -529,7 +533,7 @@ def test_epsilon_warning(self):

def test_get_filename_prefix(self):
sim = self.init_simple_simulation()
self.assertEqual(sim.get_filename_prefix(), "simulation")
self.assertEqual(sim.get_filename_prefix(), self.fname_base)
sim.filename_prefix = ''
self.assertEqual(sim.get_filename_prefix(), "")
sim.filename_prefix = False
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.