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

Remove two Pytest warnings due to numpy and pytest mocker in test_dump function #112

Merged
merged 14 commits into from
Oct 25, 2024
Merged
23 changes: 23 additions & 0 deletions news/warning.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* Two Pytest warnings due to numpy and pytest mocker in test_dump function

**Security:**

* <news item>
2 changes: 0 additions & 2 deletions requirements/build.txt
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
python
setuptools
10 changes: 7 additions & 3 deletions tests/test_diffraction_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,21 @@ def test_dump(tmp_path, mocker):
directory = Path(tmp_path)
file = directory / "testfile"
test = Diffraction_object()
test.wavelength = 1.54
test.wavelength = 1.01
bobleesj marked this conversation as resolved.
Show resolved Hide resolved
test.name = "test"
test.scat_quantity = "x-ray"
test.insert_scattering_quantity(
x, y, "q", metadata={"thing1": 1, "thing2": "thing2", "package_info": {"package2": "3.4.5"}}
)
with mocker.patch("importlib.metadata.version", return_value="3.3.0"), freeze_time("2012-01-14"):

mocker.patch("importlib.metadata.version", return_value="3.3.0")
sbillinge marked this conversation as resolved.
Show resolved Hide resolved
with freeze_time("2012-01-14"):
test.dump(file, "q")

with open(file, "r") as f:
actual = f.read()
expected = (
"[Diffraction_object]\nname = test\nwavelength = 1.54\nscat_quantity = x-ray\nthing1 = 1\n"
"[Diffraction_object]\nname = test\nwavelength = 1.01\nscat_quantity = x-ray\nthing1 = 1\n"
"thing2 = thing2\npackage_info = {'package2': '3.4.5', 'diffpy.utils': '3.3.0'}\n"
"creation_time = 2012-01-14 00:00:00\n\n"
"#### start data\n0.000000000000000000e+00 0.000000000000000000e+00\n"
Expand All @@ -262,4 +265,5 @@ def test_dump(tmp_path, mocker):
"9.000000000000000000e+00 9.000000000000000000e+00\n"
"1.000000000000000000e+01 1.000000000000000000e+01\n"
)

assert actual == expected