From 7962a0d72279a0709dab6b3b74366f76b77d27a5 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 22 Sep 2024 14:15:46 -0400 Subject: [PATCH 1/8] Move tests files to top --- src/diffpy/pdffit2/tests/__init__.py | 83 ------------------- src/diffpy/pdffit2/tests/debug.py | 35 -------- src/diffpy/pdffit2/tests/run.py | 56 ------------- .../pdffit2/tests => tests}/ExceptionsTest.py | 0 .../pdffit2/tests => tests}/TestPdfFit.py | 0 .../tests => tests}/TestPhaseFractions.py | 0 .../tests => tests}/TestShapeFactors.py | 0 .../pdffit2/tests => tests}/conftest.py | 0 .../tests => tests}/pdffit2testutils.py | 0 .../pdffit2/tests => tests}/testdata/300K.gr | 0 .../pdffit2/tests => tests}/testdata/Ni.dat | 0 .../pdffit2/tests => tests}/testdata/Ni.stru | 0 .../tests => tests}/testdata/PbScW25TiO3.stru | 0 .../tests => tests}/testdata/badNi.dat | 0 .../tests => tests}/testdata/badNi.stru | 0 .../testdata/badNiZeroVolume.stru | 0 .../tests => tests}/testdata/noLattice.stru | 0 17 files changed, 174 deletions(-) delete mode 100644 src/diffpy/pdffit2/tests/__init__.py delete mode 100644 src/diffpy/pdffit2/tests/debug.py delete mode 100644 src/diffpy/pdffit2/tests/run.py rename {src/diffpy/pdffit2/tests => tests}/ExceptionsTest.py (100%) rename {src/diffpy/pdffit2/tests => tests}/TestPdfFit.py (100%) rename {src/diffpy/pdffit2/tests => tests}/TestPhaseFractions.py (100%) rename {src/diffpy/pdffit2/tests => tests}/TestShapeFactors.py (100%) rename {src/diffpy/pdffit2/tests => tests}/conftest.py (100%) rename {src/diffpy/pdffit2/tests => tests}/pdffit2testutils.py (100%) rename {src/diffpy/pdffit2/tests => tests}/testdata/300K.gr (100%) rename {src/diffpy/pdffit2/tests => tests}/testdata/Ni.dat (100%) rename {src/diffpy/pdffit2/tests => tests}/testdata/Ni.stru (100%) rename {src/diffpy/pdffit2/tests => tests}/testdata/PbScW25TiO3.stru (100%) rename {src/diffpy/pdffit2/tests => tests}/testdata/badNi.dat (100%) rename {src/diffpy/pdffit2/tests => tests}/testdata/badNi.stru (100%) rename {src/diffpy/pdffit2/tests => tests}/testdata/badNiZeroVolume.stru (100%) rename {src/diffpy/pdffit2/tests => tests}/testdata/noLattice.stru (100%) diff --git a/src/diffpy/pdffit2/tests/__init__.py b/src/diffpy/pdffit2/tests/__init__.py deleted file mode 100644 index a27d592f..00000000 --- a/src/diffpy/pdffit2/tests/__init__.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# (c) 2012 Trustees of the Columbia University in the City of New York. -# All rights reserved. -# (c) 2024 The Trustees of Columbia University in the City of New York. -# All rights reserved. -# -# File coded by: Billinge Group members and community contributors. -# -# See GitHub contributions for a more detailed list of contributors. -# https://github.com/diffpy/diffpy.pdffit2/graphs/contributors -# -# See LICENSE.rst for license information. -# -############################################################################## - -"""Unit tests for the diffpy.pdffit2 package. -""" - -import unittest - - -def testsuite(pattern=""): - """Create a unit tests suite for the diffpy.pdffit2 package. - - Parameters - ---------- - pattern : str, optional - Regular expression pattern for selecting test cases. - Select all tests when empty. Ignore the pattern when - any of unit test modules fails to import. - - Returns - ------- - suite : `unittest.TestSuite` - The TestSuite object containing the matching tests. - """ - import re - from itertools import chain - from os.path import dirname - - from pkg_resources import resource_filename - - loader = unittest.defaultTestLoader - thisdir = resource_filename(__name__, "") - depth = __name__.count(".") + 1 - topdir = thisdir - for i in range(depth): - topdir = dirname(topdir) - suite_all = loader.discover(thisdir, pattern="*Test*.py", top_level_dir=topdir) - # always filter the suite by pattern to test-cover the selection code. - suite = unittest.TestSuite() - rx = re.compile(pattern) - tsuites = list(chain.from_iterable(suite_all)) - tsok = all(isinstance(ts, unittest.TestSuite) for ts in tsuites) - if not tsok: # pragma: no cover - return suite_all - tcases = chain.from_iterable(tsuites) - for tc in tcases: - tcwords = tc.id().split(".") - shortname = ".".join(tcwords[-3:]) - if rx.search(shortname): - suite.addTest(tc) - # verify all tests are found for an empty pattern. - assert pattern or suite_all.countTestCases() == suite.countTestCases() - return suite - - -def test(): - """Execute all unit tests for the diffpy.pdffit2 package. - - Returns - ------- - result : `unittest.TestResult` - """ - suite = testsuite() - runner = unittest.TextTestRunner() - result = runner.run(suite) - return result - - -# End of file diff --git a/src/diffpy/pdffit2/tests/debug.py b/src/diffpy/pdffit2/tests/debug.py deleted file mode 100644 index 3e30239f..00000000 --- a/src/diffpy/pdffit2/tests/debug.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# (c) 2024 The Trustees of Columbia University in the City of New York. -# All rights reserved. -# -# File coded by: Billinge Group members and community contributors. -# -# See GitHub contributions for a more detailed list of contributors. -# https://github.com/diffpy/diffpy.pdffit2/graphs/contributors -# -# See LICENSE.rst for license information. -# -############################################################################## - -""" -Convenience module for debugging the unit tests using - -python -m diffpy.pdffit2.tests.debug - -Exceptions raised by failed tests or other errors are not caught. -""" - - -if __name__ == "__main__": - import sys - - from diffpy.pdffit2.tests import testsuite - - pattern = sys.argv[1] if len(sys.argv) > 1 else "" - suite = testsuite(pattern) - suite.debug() - - -# End of file diff --git a/src/diffpy/pdffit2/tests/run.py b/src/diffpy/pdffit2/tests/run.py deleted file mode 100644 index d5c4ea41..00000000 --- a/src/diffpy/pdffit2/tests/run.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# (c) 2012 Trustees of the Columbia University in the City of New York. -# All rights reserved. -# (c) 2024 The Trustees of Columbia University in the City of New York. -# All rights reserved. -# -# File coded by: Billinge Group members and community contributors. -# -# See GitHub contributions for a more detailed list of contributors. -# https://github.com/diffpy/diffpy.pdffit2/graphs/contributors -# -# See LICENSE.rst for license information. -# -############################################################################## - -"""Convenience module for executing all unit tests with -python -m diffpy.pdffit2.tests.run -""" - - -if __name__ == "__main__": - import sys - - # show warnings by default - if not sys.warnoptions: - import os - import warnings - - warnings.simplefilter("default") - # also affect subprocesses - os.environ["PYTHONWARNINGS"] = "default" - from diffpy.pdffit2.tests import test - - # produce zero exit code for a successful test - sys.exit(not test().wasSuccessful()) - - -# Consider upgrading to pytest -# import sys -# -# import pytest -# -# if __name__ == "__main__": -# # show output results from every test function -# args = ["-v"] -# # show the message output for skipped and expected failure tests -# if len(sys.argv) > 1: -# args.extend(sys.argv[1:]) -# print("pytest arguments: {}".format(args)) -# # call pytest and exit with the return code from pytest -# exit_res = pytest.main(args) -# sys.exit(exit_res) - -# End of file diff --git a/src/diffpy/pdffit2/tests/ExceptionsTest.py b/tests/ExceptionsTest.py similarity index 100% rename from src/diffpy/pdffit2/tests/ExceptionsTest.py rename to tests/ExceptionsTest.py diff --git a/src/diffpy/pdffit2/tests/TestPdfFit.py b/tests/TestPdfFit.py similarity index 100% rename from src/diffpy/pdffit2/tests/TestPdfFit.py rename to tests/TestPdfFit.py diff --git a/src/diffpy/pdffit2/tests/TestPhaseFractions.py b/tests/TestPhaseFractions.py similarity index 100% rename from src/diffpy/pdffit2/tests/TestPhaseFractions.py rename to tests/TestPhaseFractions.py diff --git a/src/diffpy/pdffit2/tests/TestShapeFactors.py b/tests/TestShapeFactors.py similarity index 100% rename from src/diffpy/pdffit2/tests/TestShapeFactors.py rename to tests/TestShapeFactors.py diff --git a/src/diffpy/pdffit2/tests/conftest.py b/tests/conftest.py similarity index 100% rename from src/diffpy/pdffit2/tests/conftest.py rename to tests/conftest.py diff --git a/src/diffpy/pdffit2/tests/pdffit2testutils.py b/tests/pdffit2testutils.py similarity index 100% rename from src/diffpy/pdffit2/tests/pdffit2testutils.py rename to tests/pdffit2testutils.py diff --git a/src/diffpy/pdffit2/tests/testdata/300K.gr b/tests/testdata/300K.gr similarity index 100% rename from src/diffpy/pdffit2/tests/testdata/300K.gr rename to tests/testdata/300K.gr diff --git a/src/diffpy/pdffit2/tests/testdata/Ni.dat b/tests/testdata/Ni.dat similarity index 100% rename from src/diffpy/pdffit2/tests/testdata/Ni.dat rename to tests/testdata/Ni.dat diff --git a/src/diffpy/pdffit2/tests/testdata/Ni.stru b/tests/testdata/Ni.stru similarity index 100% rename from src/diffpy/pdffit2/tests/testdata/Ni.stru rename to tests/testdata/Ni.stru diff --git a/src/diffpy/pdffit2/tests/testdata/PbScW25TiO3.stru b/tests/testdata/PbScW25TiO3.stru similarity index 100% rename from src/diffpy/pdffit2/tests/testdata/PbScW25TiO3.stru rename to tests/testdata/PbScW25TiO3.stru diff --git a/src/diffpy/pdffit2/tests/testdata/badNi.dat b/tests/testdata/badNi.dat similarity index 100% rename from src/diffpy/pdffit2/tests/testdata/badNi.dat rename to tests/testdata/badNi.dat diff --git a/src/diffpy/pdffit2/tests/testdata/badNi.stru b/tests/testdata/badNi.stru similarity index 100% rename from src/diffpy/pdffit2/tests/testdata/badNi.stru rename to tests/testdata/badNi.stru diff --git a/src/diffpy/pdffit2/tests/testdata/badNiZeroVolume.stru b/tests/testdata/badNiZeroVolume.stru similarity index 100% rename from src/diffpy/pdffit2/tests/testdata/badNiZeroVolume.stru rename to tests/testdata/badNiZeroVolume.stru diff --git a/src/diffpy/pdffit2/tests/testdata/noLattice.stru b/tests/testdata/noLattice.stru similarity index 100% rename from src/diffpy/pdffit2/tests/testdata/noLattice.stru rename to tests/testdata/noLattice.stru From 8cff34c65343f3f44a9b393ec312ef2f98abaa34 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 22 Sep 2024 14:42:16 -0400 Subject: [PATCH 2/8] Add confests --- conda-recipe/run_test.py | 5 ----- pytest.ini | 2 -- tests/conftest.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) delete mode 100644 conda-recipe/run_test.py delete mode 100644 pytest.ini diff --git a/conda-recipe/run_test.py b/conda-recipe/run_test.py deleted file mode 100644 index 1432eed6..00000000 --- a/conda-recipe/run_test.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python - -import diffpy.pdffit2.tests - -assert diffpy.pdffit2.tests.test().wasSuccessful() diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 2fbf7d55..00000000 --- a/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -python_files = *Test*.py diff --git a/tests/conftest.py b/tests/conftest.py index e3b63139..9ff54bf3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,8 +2,12 @@ from pathlib import Path import pytest +import six +import diffpy.pdffit2.output # assuming this is the correct import path +import diffpy.pdffit2 + @pytest.fixture def user_filesystem(tmp_path): base_dir = Path(tmp_path) @@ -17,3 +21,27 @@ def user_filesystem(tmp_path): json.dump(home_config_data, f) yield tmp_path + +@pytest.fixture +def datafile(): + """Fixture to dynamically load any test file.""" + + def _load(filename): + return "tests/testdata/" + filename + + return _load + +@pytest.fixture +def capture_output(): + """Capture output from pdffit2 engine produced in function call.""" + + def _capture(f, *args, **kwargs): + savestdout = diffpy.pdffit2.output.stdout + fp = six.StringIO() + diffpy.pdffit2.redirect_stdout(fp) + try: + f(*args, **kwargs) + finally: + diffpy.pdffit2.redirect_stdout(savestdout) + return fp.getvalue() + return _capture From d24079dfd84566c28c0745331131e63a19b6d3ba Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 22 Sep 2024 14:42:42 -0400 Subject: [PATCH 3/8] Rename test files and apply fixture --- tests/pdffit2testutils.py | 53 ----- .../{ExceptionsTest.py => test_exceptions.py} | 212 +++++++++++++----- tests/{TestPdfFit.py => test_pdffit.py} | 112 ++++----- ...seFractions.py => test_phase_fractions.py} | 11 +- ...tShapeFactors.py => test_shape_factors.py} | 46 ++-- 5 files changed, 247 insertions(+), 187 deletions(-) delete mode 100644 tests/pdffit2testutils.py rename tests/{ExceptionsTest.py => test_exceptions.py} (79%) rename tests/{TestPdfFit.py => test_pdffit.py} (87%) rename tests/{TestPhaseFractions.py => test_phase_fractions.py} (94%) rename tests/{TestShapeFactors.py => test_shape_factors.py} (87%) diff --git a/tests/pdffit2testutils.py b/tests/pdffit2testutils.py deleted file mode 100644 index ce61aa16..00000000 --- a/tests/pdffit2testutils.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# diffpy.srreal by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2010 Trustees of the Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Pavol Juhas -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE.txt for license information. -# -############################################################################## - -"""Helper routines for running other unit tests. -Import of this module suppresses the chatty output from the C++ extension. -""" - - -import os.path - -import six - -import diffpy.pdffit2 - -# silence the C++ engine output -diffpy.pdffit2.redirect_stdout(open(os.path.devnull, "w")) - -# path variables -thisfile = locals().get("__file__", "file.py") -tests_dir = os.path.dirname(os.path.abspath(thisfile)) -testdata_dir = os.path.join(tests_dir, "testdata") - - -def datafile(filename): - """prepend testdata_dir to filename.""" - return os.path.join(testdata_dir, filename) - - -def capture_output(f, *args, **kwargs): - """Capture output from pdffit2 engine produced in function call.""" - savestdout = diffpy.pdffit2.output.stdout - fp = six.StringIO() - diffpy.pdffit2.redirect_stdout(fp) - try: - f(*args, **kwargs) - finally: - diffpy.pdffit2.redirect_stdout(savestdout) - return fp.getvalue() - - -# End of file diff --git a/tests/ExceptionsTest.py b/tests/test_exceptions.py similarity index 79% rename from tests/ExceptionsTest.py rename to tests/test_exceptions.py index 5dee1b75..917326ff 100644 --- a/tests/ExceptionsTest.py +++ b/tests/test_exceptions.py @@ -15,12 +15,16 @@ import unittest +import pytest from diffpy.pdffit2 import PdfFit, pdffit2 -from diffpy.pdffit2.tests.pdffit2testutils import datafile class read_structExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() @@ -33,15 +37,19 @@ def test_IOError(self): def test_structureError(self): """raise pdffit2.structureError when structure is malformed""" - self.assertRaises(pdffit2.structureError, self.P.read_struct, datafile("badNi.stru")) + self.assertRaises(pdffit2.structureError, self.P.read_struct, self.datafile("badNi.stru")) def test_structureErrorZeroVolume(self): """raise pdffit2.structureError when unit cell volume is negative""" # I don't know how to test for this, but it's in the library code - self.assertRaises(pdffit2.structureError, self.P.read_struct, datafile("badNiZeroVolume.stru")) + self.assertRaises(pdffit2.structureError, self.P.read_struct, self.datafile("badNiZeroVolume.stru")) class read_dataExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() @@ -54,10 +62,14 @@ def test_IOError(self): def test_dataError(self): """raise pdffit2.dataError when data has improper spacing""" - self.assertRaises(pdffit2.dataError, self.P.read_data, datafile("badNi.dat"), "X", 25.0, 0.5) + self.assertRaises(pdffit2.dataError, self.P.read_data, self.datafile("badNi.dat"), "X", 25.0, 0.5) class read_data_listsExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.r_data = [0.1, 0.2] @@ -95,6 +107,10 @@ def test_dataError(self): class pdfrangeExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.iset = 1 @@ -110,16 +126,20 @@ def test_ValueError1(self): def test_ValueError2(self): """raise ValueError when rmax < rmin""" - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.5) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.5) self.assertRaises(ValueError, self.P.pdfrange, self.iset, self.rmax, self.rmin) def test_ValueError3(self): """raise ValueError when range outside of data""" - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.5) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.5) self.assertRaises(ValueError, self.P.pdfrange, self.iset, -self.rmin, self.rmax) class allocExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.qmax = 25 @@ -133,44 +153,48 @@ def tearDown(self): def test_ValueError1(self): """raise ValueError when qmax < 0""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", -self.qmax, self.qdamp, self.rmin, self.rmax, self.bin) def test_ValueError2(self): """raise ValueError when qdamp < 0""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", self.qmax, -self.qdamp, self.rmin, self.rmax, self.bin) def test_ValueError3(self): """raise ValueError when rmin < 0""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", self.qmax, self.qdamp, -self.rmin, self.rmax, self.bin) def test_ValueError4(self): """raise ValueError when rmax < 0""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", self.qmax, self.qdamp, self.rmin, -self.rmax, self.bin) def test_ValueError5(self): """raise ValueError when bin < 0""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", self.qmax, self.qdamp, self.rmin, self.rmax, -self.bin) def test_ValueError6(self): """raise ValueError when rmax < rmin""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", self.qmax, self.qdamp, self.rmax, self.rmin, self.bin) def test_ValueError7(self): """raise ValueError when qdamp < 0""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.alloc, "X", self.qmax, self.qdamp, self.rmin, self.rmax, -self.bin) class calcExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) def tearDown(self): del self.P @@ -224,6 +248,10 @@ def test_unassignedError(self): class save_pdfExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.strufile = "temp.pdf" @@ -233,7 +261,7 @@ def tearDown(self): def test_IOError(self): """raise IOError when structure cannot be saved""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 30.0, 0.05, 2, 10, 100) self.P.calc() self.assertRaises(IOError, self.P.save_pdf, 1, "nodir183160/" + self.strufile) @@ -244,6 +272,10 @@ def test_unassignedError(self): class save_difExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.strufile = "temp.dif" @@ -253,10 +285,10 @@ def tearDown(self): def test_IOError(self): """raise IOError when dif cannot be saved""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 30.0, 0.05, 2, 10, 100) self.P.calc() - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.5) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.5) self.assertRaises(IOError, self.P.save_dif, 1, "nodir183160/" + self.strufile) def test_unassignedError(self): @@ -265,6 +297,10 @@ def test_unassignedError(self): class save_resExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.resfile = "temp.res" @@ -274,8 +310,8 @@ def tearDown(self): def test_IOError(self): """raise IOError when residual file cannot be saved""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_data(datafile("Ni.dat"), "X", 30.0, 0.0) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_data(self.datafile("Ni.dat"), "X", 30.0, 0.0) self.P.constrain(self.P.lat(1), 1) self.P.setpar(1, 3.0) self.P.pdfrange(1, 2.0, 10.0) @@ -288,6 +324,10 @@ def test_unassignedError(self): class save_structExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + # Same code as show_struct def setUp(self): @@ -299,7 +339,7 @@ def tearDown(self): def test_IOError(self): """raise IOError when structure cannot be saved""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(IOError, self.P.save_struct, 1, "nodir183160/" + self.strufile) def test_unassignedError(self): @@ -308,6 +348,10 @@ def test_unassignedError(self): class constrainExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.par = 1 @@ -319,8 +363,8 @@ def tearDown(self): def test_constraintError(self): """raise constraintError when constraint is bad""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.P.constrain("x(1)", "junk+@1") self.P.setpar(1, 0.01) self.assertRaises(pdffit2.constraintError, self.P.calc) @@ -334,14 +378,14 @@ def test_unassignedError(self): def test_ValueError(self): """raise ValueError when a variable index does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.constrain, self.P.x(6), self.par) return def test_constrainNonRefVar(self): "raise constraintError when attempting to constrain non-refinables" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(pdffit2.constraintError, self.P.constrain, "rcut", "@7") self.assertRaises(pdffit2.constraintError, self.P.constrain, "rcut", 13) self.assertRaises(pdffit2.constraintError, self.P.constrain, "stepcut", "@17") @@ -349,6 +393,10 @@ def test_constrainNonRefVar(self): class setvarExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.val = 3.0 @@ -362,11 +410,15 @@ def test_unassignedError(self): def test_ValueError(self): """raise ValueError when a variable index does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.setvar, self.P.lat(7), self.val) class getvarExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() @@ -379,7 +431,7 @@ def test_unassignedError(self): def test_ValueError(self): """raise ValueError when a variable index does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.getvar, self.P.lat(7)) @@ -444,6 +496,10 @@ def test_unassignedError(self): class getparExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() @@ -456,7 +512,7 @@ def test_unassignedError1(self): def test_unassignedError2(self): """raise pdffit2.unassignedError when parameter does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.constrain(self.P.lat(1), 2) self.assertRaises(pdffit2.unassignedError, self.P.getpar, 1) @@ -479,6 +535,10 @@ def test_unassignedError2(self): class pdeselExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.ip = 1 @@ -492,11 +552,15 @@ def test_unassignedError1(self): def test_unassignedError2(self): """raise pdffit2.unassignedError when phase does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(pdffit2.unassignedError, self.P.pdesel, self.ip) class selectAtomTypeExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.iset = 1 @@ -511,9 +575,9 @@ def test_unassignedError1(self): def test_unassignedError2(self): """raise pdffit2.unassignedError when set does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) # selectAtomType should pass with one phase defined - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.P.selectAtomType(self.iset, "i", "Ni", True) self.P.selectAtomType(self.iset, "j", "Ni", False) # but fail for phase 2 which is not present @@ -521,14 +585,18 @@ def test_unassignedError2(self): def test_ijcharValueError(self): """raise ValueError when ijchar is neither 'i' nor 'j'""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.P.selectAtomType(self.iset, "i", "Ni", True) self.P.selectAtomType(self.iset, "j", "Ni", True) self.assertRaises(ValueError, self.P.selectAtomType, self.iset, "k", "Ni", True) class selectAtomIndexExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.iset = 1 @@ -543,9 +611,9 @@ def test_unassignedError1(self): def test_unassignedError2(self): """raise pdffit2.unassignedError when set does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) # pass for phase 1 - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.P.selectAtomIndex(self.iset, "i", 1, True) self.P.selectAtomIndex(self.iset, "i", 2, False) # fail for phase 2 @@ -553,12 +621,16 @@ def test_unassignedError2(self): def test_ValueError(self): """raise ValueError when selected atom does not exist""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(ValueError, self.P.selectAtomIndex, self.iset, "i", 6, True) class selectAllExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.iset = 1 @@ -573,11 +645,11 @@ def test_unassignedError1(self): def test_unassignedError2(self): """raise pdffit2.unassignedError when set does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) # fail when there is no dataset self.assertRaises(pdffit2.unassignedError, self.P.selectAll, self.iset, "i") # pass with dataset - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.P.selectAll(self.iset, "i") self.P.selectAll(self.iset, "j") # fail for phase 2 @@ -586,6 +658,10 @@ def test_unassignedError2(self): class selectNoneExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.iset = 1 @@ -600,11 +676,11 @@ def test_unassignedError1(self): def test_unassignedError2(self): """raise pdffit2.unassignedError when set does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) # fail when there is no dataset self.assertRaises(pdffit2.unassignedError, self.P.selectNone, self.iset, "i") # pass with dataset - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.P.selectNone(self.iset, "i") self.P.selectNone(self.iset, "j") # fail for phase 2 @@ -613,6 +689,10 @@ def test_unassignedError2(self): class bangExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.a1 = 1 @@ -628,22 +708,26 @@ def test_unassignedError(self): def test_ValueError1(self): """raise ValueError when selected atom(s) does not exist""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(ValueError, self.P.bang, 0, self.a2, self.a3) def test_ValueError2(self): """raise ValueError when selected atom(s) does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.bang, self.a1, -1, self.a3) def test_ValueError3(self): """raise ValueError when selected atom(s) does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.bang, self.a1, self.a2, 6) class blenExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() self.a1 = 1 @@ -658,17 +742,17 @@ def test_unassignedError(self): def test_ValueError1(self): """raise ValueError when selected atom(s) does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.blen, 0, self.a2) def test_ValueError2(self): """raise ValueError when selected atom(s) does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.blen, self.a1, 6) def test_ValueError3(self): """raise ValueError when selected atom(s) does not exist""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertRaises(ValueError, self.P.blen, 0, 6) @@ -716,6 +800,10 @@ def test_unassignedError(self): class fixparExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() @@ -724,12 +812,16 @@ def tearDown(self): def test_unassignedError(self): """raise pdffit2.unassignedError when parameter does not exist""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(pdffit2.unassignedError, self.P.fixpar, 1) class freeparExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() @@ -738,12 +830,16 @@ def tearDown(self): def test_unassignedError(self): """raise pdffit2.unassignedError when parameter does not exist""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(pdffit2.unassignedError, self.P.freepar, 1) class setphaseExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() @@ -752,12 +848,16 @@ def tearDown(self): def test_unassignedError(self): """raise pdffit2.unassignedError when phase does not exist""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(pdffit2.unassignedError, self.P.setphase, 2) class setdataExceptions(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() @@ -766,8 +866,8 @@ def tearDown(self): def test_unassignedError(self): """raise pdffit2.unassignedError when data set does not exist""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.assertRaises(pdffit2.unassignedError, self.P.setdata, 2) diff --git a/tests/TestPdfFit.py b/tests/test_pdffit.py similarity index 87% rename from tests/TestPdfFit.py rename to tests/test_pdffit.py index 70712356..ed389978 100644 --- a/tests/TestPdfFit.py +++ b/tests/test_pdffit.py @@ -4,9 +4,8 @@ """ import unittest - +import pytest from diffpy.pdffit2 import PdfFit, pdffit2 -from diffpy.pdffit2.tests.pdffit2testutils import capture_output, datafile from diffpy.structure import loadStructure # ---------------------------------------------------------------------------- @@ -15,6 +14,11 @@ class TestPdfFit(unittest.TestCase): places = 6 + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile, capture_output): + self.datafile = datafile + self.capture_output = capture_output + def setUp(self): self.P = PdfFit() return @@ -42,7 +46,7 @@ def test__exportAll(self): def test_add_structure(self): """check PdfFit.add_structure()""" - ni = loadStructure(datafile("Ni.stru")) + ni = loadStructure(self.datafile("Ni.stru")) self.P.add_structure(ni) self.assertEqual(4, self.P.num_atoms()) return @@ -65,7 +69,7 @@ def test_add_structure(self): def test_read_data_string(self): """check PdfFit.read_data_string()""" pf = self.P - with open(datafile("300K.gr")) as fp: + with open(self.datafile("300K.gr")) as fp: s = fp.read() self.assertEqual([], pf.data_files) pf.read_data_string(s, "N", 32, 0.03, "lmo") @@ -99,7 +103,7 @@ def test_alloc(self): self.P.calc() Gzero = self.P.getpdf_fit() self.assertEqual(1000 * [0.0], Gzero) - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.calc() # check r-values r = self.P.getR() @@ -109,7 +113,7 @@ def test_alloc(self): Gfit_alloc_read = self.P.getpdf_fit() # now try the other order self.P.reset() - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 25, 0.0, 0.01, 10, 1000) self.P.calc() Gfit_read_alloc = self.P.getpdf_fit() @@ -164,8 +168,8 @@ def test_alloc(self): def test_get_structure(self): """check PdfFit.get_structure()""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) stru1 = self.P.get_structure(1) self.assertEqual(4, len(stru1)) self.assertEqual("Ni", stru1[0].element) @@ -197,7 +201,7 @@ def test_get_structure(self): def test_setpar(self): """check PdfFit.setpar()""" pf = self.P - pf.read_struct(datafile("Ni.stru")) + pf.read_struct(self.datafile("Ni.stru")) pf.setpar(1, "lat(1)") self.assertEqual(3.52, pf.getpar(1)) pf.setpar(1, 4.0) @@ -209,7 +213,7 @@ def test_setpar(self): def test_setvar(self): """check PdfFit.setvar()""" pf = self.P - pf.read_struct(datafile("Ni.stru")) + pf.read_struct(self.datafile("Ni.stru")) pf.setvar(pf.delta1, 1.2) self.assertEqual(1.2, pf.getvar(pf.delta1)) pf.setvar("delta1", 1.7) @@ -248,8 +252,8 @@ def test_setvar(self): def test_get_atoms(self): """check PdfFit.get_atoms()""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.setphase(1) a1 = self.P.get_atoms() a2 = self.P.get_atoms(2) @@ -259,8 +263,8 @@ def test_get_atoms(self): def test_get_atom_types(self): """check PdfFit.get_atom_types()""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.setphase(1) atp1 = self.P.get_atom_types() atp2 = self.P.get_atom_types(2) @@ -271,9 +275,9 @@ def test_get_atom_types(self): def test_num_phases(self): """check PdfFit.num_phases()""" self.assertEqual(0, self.P.num_phases()) - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertEqual(1, self.P.num_phases()) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.assertEqual(2, self.P.num_phases()) self.P.reset() self.assertEqual(0, self.P.num_phases()) @@ -282,17 +286,17 @@ def test_num_phases(self): def test_num_datasets(self): """check PdfFit.num_datasets()""" self.assertEqual(0, self.P.num_datasets()) - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.5) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.5) self.assertEqual(1, self.P.num_datasets()) # failed data should not increase num_datasets try: - self.P.read_data(datafile("badNi.dat")) + self.P.read_data(self.datafile("badNi.dat")) except (RuntimeError, TypeError, NameError, ValueError, IOError): pass self.assertEqual(1, self.P.num_datasets()) # alloc should increase number of datasets # alloc requires a loaded structure - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 30.0, 0.05, 2, 10, 100) self.assertEqual(2, self.P.num_datasets()) self.P.reset() @@ -306,10 +310,10 @@ def test_getcrw(self): self.assertEqual(0, self.P.num_datasets()) # Setting qmax=0 so that partial crw are not disturbed by # termination ripples. - self.P.read_data(datafile("Ni.dat"), "X", 0.0, 0.0) + self.P.read_data(self.datafile("Ni.dat"), "X", 0.0, 0.0) # crw is empty before data refinement self.assertEqual([], self.P.getcrw()) - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.pdfrange(1, 2, 19) self.P.refine() crw19 = numpy.array(self.P.getcrw()) @@ -334,11 +338,11 @@ def test_getcrw(self): def test_getcrw_two_datasets(self): """check that getcrw() and getrw() are consistent for two datasets.""" - self.P.read_data(datafile("Ni.dat"), "X", 25.0, 0.0) + self.P.read_data(self.datafile("Ni.dat"), "X", 25.0, 0.0) self.P.pdfrange(1, 2, 8) - self.P.read_data(datafile("300K.gr"), "N", 32.0, 0.0) + self.P.read_data(self.datafile("300K.gr"), "N", 32.0, 0.0) self.P.pdfrange(2, 1, 11) - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) # mess lattice parameters to have comparable Rw contributions self.P.setvar("lat(1)", 3) self.P.setvar("lat(2)", 3) @@ -389,18 +393,18 @@ def doalloc(): self.assertRaises(pdffit2.unassignedError, self.P.psel, 0) self.assertRaises(pdffit2.unassignedError, self.P.psel, 1) - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) doalloc() self.P.calc() G1 = self.P.getpdf_fit() self.P.reset() - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) doalloc() self.P.calc() G2 = self.P.getpdf_fit() self.P.reset() - self.P.read_struct(datafile("Ni.stru")) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) doalloc() self.P.pdesel("ALL") self.P.psel(1) @@ -429,18 +433,18 @@ def doalloc(): self.assertRaises(pdffit2.unassignedError, self.P.pdesel, 0) self.assertRaises(pdffit2.unassignedError, self.P.pdesel, 1) - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) doalloc() self.P.calc() G1 = self.P.getpdf_fit() self.P.reset() - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) doalloc() self.P.calc() G2 = self.P.getpdf_fit() self.P.reset() - self.P.read_struct(datafile("Ni.stru")) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) doalloc() self.P.psel("ALL") self.P.pdesel(2) @@ -482,7 +486,7 @@ def doalloc(): def test_bond_angle(self): """check PdfFit.bond_angle()""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) a, e = self.P.bond_angle(1, 2, 3) self.assertAlmostEqual(60.0, a, self.places) self.assertRaises(ValueError, self.P.bond_angle, 0, 1, 2) @@ -491,16 +495,16 @@ def test_bond_angle(self): def test_bang(self): "check PdfFit.bang() function" - self.P.read_struct(datafile("Ni.stru")) - out = capture_output(self.P.bang, 1, 2, 3).strip() + self.P.read_struct(self.datafile("Ni.stru")) + out = self.capture_output(self.P.bang, 1, 2, 3).strip() self.assertTrue(out.endswith("60 degrees")) self.assertTrue(out.startswith("NI (#1) - NI (#2) - NI (#3)")) return def test_bond_length_atoms(self): """check PdfFit.bond_length_atoms()""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) dij, ddij = self.P.bond_length_atoms(1, 5) self.assertAlmostEqual(4.03635, dij, self.places) self.P.setphase(1) @@ -509,8 +513,8 @@ def test_bond_length_atoms(self): def test_bond_length_types(self): """check PdfFit.bond_length_types()""" - self.P.read_struct(datafile("Ni.stru")) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) dPbO = self.P.bond_length_types("Pb", "O", 0.1, 3.0) # check if keys are present self.assertTrue("dij" in dPbO) @@ -551,19 +555,19 @@ def test_bond_length_types(self): def test_blen(self): """check PdfFit.blen()""" - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) blen = self.P.blen - o = capture_output(blen, 1, 5).strip() + o = self.capture_output(blen, 1, 5).strip() self.assertTrue(o.endswith("4.03635 A")) self.assertTrue("PB (#1)" in o) self.assertTrue("PB (#5)" in o) self.assertRaises(ValueError, blen, 1, 99) self.assertRaises(ValueError, blen, 0, 1) - o1 = capture_output(blen, 1, 1, 0.1, 1) + o1 = self.capture_output(blen, 1, 1, 0.1, 1) self.assertTrue("No pairs found" in o1) - o2 = capture_output(blen, 1, 50, 0.1, 1) + o2 = self.capture_output(blen, 1, 50, 0.1, 1) self.assertEqual("", o2) - o3 = capture_output(blen, "Sc", "O", 0.5, 2.3).strip() + o3 = self.capture_output(blen, "Sc", "O", 0.5, 2.3).strip() self.assertEqual(1 + 48, len(o3.split("\n"))) self.assertEqual(6, o3.count("SC (#33)")) self.assertEqual(2, o3.count("O (#9)")) @@ -604,11 +608,11 @@ def test_set_scat(self): # check if it is local to phase fPb = self.P.get_scat("X", "Pb") bPb = self.P.get_scat("N", "Pb") - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.set_scat("X", "Pb", 142) self.assertEqual(142, self.P.get_scat("X", "Pb")) self.assertEqual(bPb, self.P.get_scat("N", "Pb")) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.assertEqual(fPb, self.P.get_scat("X", "Pb")) self.P.setphase(1) self.assertEqual(142, self.P.get_scat("X", "Pb")) @@ -626,9 +630,9 @@ def test_reset_scat(self): # check if it is local to phase fPb = self.P.get_scat("X", "Pb") bPb = self.P.get_scat("N", "Pb") - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.set_scat("X", "Pb", 142) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.set_scat("N", "Pb", -17) self.P.setphase(1) self.assertNotEqual(fPb, self.P.get_scat("X", "Pb")) @@ -644,9 +648,9 @@ def test_reset_scat(self): def test_num_atoms(self): """check PdfFit.num_atoms()""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertEqual(4, self.P.num_atoms()) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.assertEqual(56, self.P.num_atoms()) self.P.setphase(1) self.assertEqual(4, self.P.num_atoms()) @@ -657,7 +661,7 @@ def test_num_atoms(self): def test_lat(self): """check PdfFit.lat()""" pf = self.P - pf.read_struct(datafile("Ni.stru")) + pf.read_struct(self.datafile("Ni.stru")) for i in ("a", "b", "c", 1, 2, 3): self.assertEqual(3.52, pf.getvar(pf.lat(i))) for i in ("alpha", "beta", "gamma", 4, 5, 6): @@ -667,7 +671,7 @@ def test_lat(self): def test_xyz(self): """check PdfFit.x() PdfFit.y(), PdfFit.z()""" pf = self.P - pf.read_struct(datafile("Ni.stru")) + pf.read_struct(self.datafile("Ni.stru")) self.assertEqual(0.5, pf.getvar(pf.x(3))) self.assertEqual(0, pf.getvar(pf.y(3))) self.assertEqual(0.5, pf.getvar(pf.z(3))) @@ -675,7 +679,7 @@ def test_xyz(self): def test_uij(self): """check PdfFit.uij()""" - ni = loadStructure(datafile("Ni.stru")) + ni = loadStructure(self.datafile("Ni.stru")) ni[2].anisotropy = True ni[2].U11, ni[2].U22, ni[2].U33 = 1, 2, 3 ni[2].U12, ni[2].U13, ni[2].U23 = 4, 5, 6 @@ -692,7 +696,7 @@ def test_uij(self): def test_occ(self): """check PdfFit.occ()""" pf = self.P - pf.read_struct(datafile("Ni.stru")) + pf.read_struct(self.datafile("Ni.stru")) for i in range(1, 5): self.assertEqual(1, pf.getvar(pf.occ(i))) return diff --git a/tests/TestPhaseFractions.py b/tests/test_phase_fractions.py similarity index 94% rename from tests/TestPhaseFractions.py rename to tests/test_phase_fractions.py index afc57c06..3870c12f 100644 --- a/tests/TestPhaseFractions.py +++ b/tests/test_phase_fractions.py @@ -4,19 +4,22 @@ """ import unittest - +import pytest from diffpy.pdffit2 import PdfFit -from diffpy.pdffit2.tests.pdffit2testutils import datafile ############################################################################## class TestPhaseFractions(unittest.TestCase): places = 4 + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + def setUp(self): self.P = PdfFit() - self.P.read_struct(datafile("Ni.stru")) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.alloc("N", 0.0, 0.05, 0.1, 10, 200) return diff --git a/tests/TestShapeFactors.py b/tests/test_shape_factors.py similarity index 87% rename from tests/TestShapeFactors.py rename to tests/test_shape_factors.py index 1eaa9711..e59e4225 100644 --- a/tests/TestShapeFactors.py +++ b/tests/test_shape_factors.py @@ -5,11 +5,10 @@ import unittest - +import pytest import numpy from diffpy.pdffit2 import PdfFit, pdffit2 -from diffpy.pdffit2.tests.pdffit2testutils import datafile def spherefactor(r, d): @@ -30,6 +29,9 @@ def spherefactor(r, d): class TestSphereEnvelope(unittest.TestCase): places = 6 + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile def setUp(self): self.P = PdfFit() @@ -41,7 +43,7 @@ def tearDown(self): def test_calculation(self): """check calculation of sphere envelope factor""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.calc() d = 8.0 @@ -59,7 +61,7 @@ def test_refinement(self): """check refinement of sphere envelope factor""" dcheck = 8.0 dstart = 12.0 - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.setvar("spdiameter", dcheck) self.P.calc() @@ -69,7 +71,7 @@ def test_refinement(self): Gd8noise[::2] += 0.01 Gd8noise[1::2] -= 0.01 self.P.reset() - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.read_data_lists("X", 0.0, 0.05, list(r), list(Gd8noise)) self.P.constrain("spdiameter", "@8") self.P.setpar(8, dstart) @@ -82,20 +84,20 @@ def test_twophase_calculation(self): """check PDF calculation for 2 phases with different spdiameters""" d1 = 6 d2 = 9 - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.setvar("spdiameter", d1) self.P.calc() G1 = numpy.array(self.P.getpdf_fit()) self.P.reset() - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.setvar("spdiameter", d2) self.P.calc() G2 = numpy.array(self.P.getpdf_fit()) self.P.reset() - self.P.read_struct(datafile("Ni.stru")) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.setphase(1) self.P.setvar("spdiameter", d1) @@ -115,13 +117,13 @@ def test_twophase_refinement(self): dstart1 = 8.2 dcheck2 = 6.0 dstart2 = 5.5 - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.setvar("spdiameter", dcheck1) self.P.calc() G1 = numpy.array(self.P.getpdf_fit()) self.P.reset() - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.setvar("spdiameter", dcheck2) self.P.calc() @@ -131,8 +133,8 @@ def test_twophase_refinement(self): Gnoise[::2] += 0.01 Gnoise[1::2] -= 0.01 self.P.reset() - self.P.read_struct(datafile("Ni.stru")) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.read_data_lists("X", 0.0, 0.05, list(r), list(Gnoise)) self.P.setphase(1) self.P.constrain("spdiameter", "@11") @@ -152,7 +154,7 @@ def test_spdiameter_io(self): """Check reading and writing of spdiameter from structure file.""" import re - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertEqual(0.0, self.P.getvar("spdiameter")) # engine should not write shape factor when not defined spdnone = self.P.save_struct_string(1) @@ -180,6 +182,10 @@ def test_spdiameter_io(self): ############################################################################## class TestStepCutEnvelope(unittest.TestCase): + @pytest.fixture(autouse=True) + def prepare_fixture(self, datafile): + self.datafile = datafile + places = 6 def setUp(self): @@ -192,7 +198,7 @@ def tearDown(self): def test_stepcut_calculation(self): """check calculation of sphere envelope factor""" - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.calc() stepcut = 8.0 @@ -211,20 +217,20 @@ def test_twophase_stepcut_calculation(self): """check PDF calculation for 2 phases with different spdiameters""" d1 = 6 d2 = 9 - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.setvar("stepcut", d1) self.P.calc() G1 = numpy.array(self.P.getpdf_fit()) self.P.reset() - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.setvar("stepcut", d2) self.P.calc() G2 = numpy.array(self.P.getpdf_fit()) self.P.reset() - self.P.read_struct(datafile("Ni.stru")) - self.P.read_struct(datafile("PbScW25TiO3.stru")) + self.P.read_struct(self.datafile("Ni.stru")) + self.P.read_struct(self.datafile("PbScW25TiO3.stru")) self.P.alloc("X", 0.0, 0.05, 0.1, 10, 200) self.P.setphase(1) self.P.setvar("stepcut", d1) @@ -244,7 +250,7 @@ def test_stepcut_io(self): """Check reading and writing of stepcut from structure file.""" import re - self.P.read_struct(datafile("Ni.stru")) + self.P.read_struct(self.datafile("Ni.stru")) self.assertEqual(0.0, self.P.getvar("stepcut")) # engine should not write shape factor when not defined sscnone = self.P.save_struct_string(1) From 45304fabec2aedb871d188039f5d82120a37c460 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 22 Sep 2024 14:44:37 -0400 Subject: [PATCH 4/8] Apply pre-commit --- tests/conftest.py | 7 +++-- tests/test_exceptions.py | 51 ++++++++++++++++++----------------- tests/test_pdffit.py | 4 ++- tests/test_phase_fractions.py | 2 ++ tests/test_shape_factors.py | 4 ++- 5 files changed, 39 insertions(+), 29 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 9ff54bf3..5407f543 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,10 +3,10 @@ import pytest import six -import diffpy.pdffit2.output # assuming this is the correct import path - import diffpy.pdffit2 +import diffpy.pdffit2.output # assuming this is the correct import path + @pytest.fixture def user_filesystem(tmp_path): @@ -22,6 +22,7 @@ def user_filesystem(tmp_path): yield tmp_path + @pytest.fixture def datafile(): """Fixture to dynamically load any test file.""" @@ -31,6 +32,7 @@ def _load(filename): return _load + @pytest.fixture def capture_output(): """Capture output from pdffit2 engine produced in function call.""" @@ -44,4 +46,5 @@ def _capture(f, *args, **kwargs): finally: diffpy.pdffit2.redirect_stdout(savestdout) return fp.getvalue() + return _capture diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 917326ff..f2f245ce 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -15,6 +15,7 @@ import unittest + import pytest from diffpy.pdffit2 import PdfFit, pdffit2 @@ -24,7 +25,7 @@ class read_structExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() @@ -49,7 +50,7 @@ class read_dataExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() @@ -69,7 +70,7 @@ class read_data_listsExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.r_data = [0.1, 0.2] @@ -110,7 +111,7 @@ class pdfrangeExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.iset = 1 @@ -139,7 +140,7 @@ class allocExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.qmax = 25 @@ -191,7 +192,7 @@ class calcExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.P.read_struct(self.datafile("Ni.stru")) @@ -251,7 +252,7 @@ class save_pdfExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.strufile = "temp.pdf" @@ -275,7 +276,7 @@ class save_difExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.strufile = "temp.dif" @@ -300,7 +301,7 @@ class save_resExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.resfile = "temp.res" @@ -327,7 +328,7 @@ class save_structExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + # Same code as show_struct def setUp(self): @@ -351,7 +352,7 @@ class constrainExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.par = 1 @@ -396,7 +397,7 @@ class setvarExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.val = 3.0 @@ -418,7 +419,7 @@ class getvarExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() @@ -499,7 +500,7 @@ class getparExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() @@ -538,7 +539,7 @@ class pdeselExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.ip = 1 @@ -560,7 +561,7 @@ class selectAtomTypeExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.iset = 1 @@ -596,7 +597,7 @@ class selectAtomIndexExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.iset = 1 @@ -630,7 +631,7 @@ class selectAllExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.iset = 1 @@ -661,7 +662,7 @@ class selectNoneExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.iset = 1 @@ -692,7 +693,7 @@ class bangExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.a1 = 1 @@ -727,7 +728,7 @@ class blenExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() self.a1 = 1 @@ -803,7 +804,7 @@ class fixparExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() @@ -821,7 +822,7 @@ class freeparExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() @@ -839,7 +840,7 @@ class setphaseExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() @@ -857,7 +858,7 @@ class setdataExceptions(unittest.TestCase): @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile - + def setUp(self): self.P = PdfFit() diff --git a/tests/test_pdffit.py b/tests/test_pdffit.py index ed389978..68c06833 100644 --- a/tests/test_pdffit.py +++ b/tests/test_pdffit.py @@ -4,7 +4,9 @@ """ import unittest + import pytest + from diffpy.pdffit2 import PdfFit, pdffit2 from diffpy.structure import loadStructure @@ -18,7 +20,7 @@ class TestPdfFit(unittest.TestCase): def prepare_fixture(self, datafile, capture_output): self.datafile = datafile self.capture_output = capture_output - + def setUp(self): self.P = PdfFit() return diff --git a/tests/test_phase_fractions.py b/tests/test_phase_fractions.py index 3870c12f..d4df1c60 100644 --- a/tests/test_phase_fractions.py +++ b/tests/test_phase_fractions.py @@ -4,7 +4,9 @@ """ import unittest + import pytest + from diffpy.pdffit2 import PdfFit diff --git a/tests/test_shape_factors.py b/tests/test_shape_factors.py index e59e4225..dd0a0e9c 100644 --- a/tests/test_shape_factors.py +++ b/tests/test_shape_factors.py @@ -5,8 +5,9 @@ import unittest -import pytest + import numpy +import pytest from diffpy.pdffit2 import PdfFit, pdffit2 @@ -29,6 +30,7 @@ def spherefactor(r, d): class TestSphereEnvelope(unittest.TestCase): places = 6 + @pytest.fixture(autouse=True) def prepare_fixture(self, datafile): self.datafile = datafile From 5cb4cb5a81c3b793f276d258942773df95379e70 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 22 Sep 2024 15:58:26 -0400 Subject: [PATCH 5/8] Remove -e --- .github/workflows/matrix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml index a4f39eca..3c8c0f0d 100644 --- a/.github/workflows/matrix.yml +++ b/.github/workflows/matrix.yml @@ -42,7 +42,7 @@ jobs: conda install --file requirements/test.txt conda install --file requirements/build.txt python -m pip install -r requirements/pip.txt - python -m pip install -e . --no-deps + python -m pip install . --no-deps - name: Validate diffpy.pdffit2 run: python -m pytest From f3e16358462452ce8a608c8cf9db805a62918327 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 22 Sep 2024 15:58:38 -0400 Subject: [PATCH 6/8] Remove -e in main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6b42f847..30f4e0a4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,7 +37,7 @@ jobs: conda install --file requirements/test.txt conda install --file requirements/build.txt python -m pip install -r requirements/pip.txt - python -m pip install -e . --no-deps + python -m pip install . --no-deps - name: Validate diffpy.pdffit2 run: python -m pytest From 84411db21564f3416d07ce0359e6faeb47b953fd Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 22 Sep 2024 15:58:50 -0400 Subject: [PATCH 7/8] Remove -e in docs.yml --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a6f0e236..89ff2948 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -36,7 +36,7 @@ jobs: conda install --file requirements/run.txt conda install --file requirements/docs.txt python -m pip install -r requirements/pip.txt - python -m pip install -e . --no-deps + python -m pip install . --no-deps - name: build documents run: make -C doc html From f9cae2c58154dcc5b0b940bd410d9d9276949946 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 22 Sep 2024 15:59:01 -0400 Subject: [PATCH 8/8] Remove -e in codecov.yml --- .github/workflows/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 66a8baa5..b2b039f2 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -40,7 +40,7 @@ jobs: conda install --file requirements/test.txt conda install --file requirements/build.txt python -m pip install -r requirements/pip.txt - python -m pip install -e . --no-deps + python -m pip install . --no-deps - name: Validate diffpy.pdffit2 run: |