Skip to content

Commit bfc9b47

Browse files
authored
Merge pull request #100 from bobleesj/tests-folder
Move tests folder to top dir level
2 parents b0271c0 + 8cfba38 commit bfc9b47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+182
-292
lines changed

news/folder.rst

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* tests folder at the root of the repo
20+
21+
**Security:**
22+
23+
* <news item>

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dirty_template = "{tag}"
4545
[tool.setuptools.packages.find]
4646
where = ["src"] # list of folders that contain the packages (["."] by default)
4747
include = ["*"] # package names should match these glob patterns (["*"] by default)
48-
exclude = ["diffpy.structure.tests*"] # exclude packages matching these glob patterns (empty by default)
48+
exclude = [] # exclude packages matching these glob patterns (empty by default)
4949
namespaces = false # to disable scanning PEP 420 namespaces (true by default)
5050

5151
[tool.setuptools.dynamic]

src/diffpy/structure/tests/__init__.py

-77
This file was deleted.

src/diffpy/structure/tests/debug.py

-35
This file was deleted.

src/diffpy/structure/tests/run.py

-36
This file was deleted.

src/diffpy/structure/tests/testutils.py

-25
This file was deleted.

src/diffpy/structure/tests/conftest.py renamed to tests/conftest.py

+10
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,13 @@ def user_filesystem(tmp_path):
1717
json.dump(home_config_data, f)
1818

1919
yield tmp_path
20+
21+
22+
@pytest.fixture
23+
def datafile():
24+
"""Fixture to dynamically load any test file."""
25+
26+
def _load(filename):
27+
return "tests/testdata/" + filename
28+
29+
return _load
File renamed without changes.
File renamed without changes.

src/diffpy/structure/tests/test_loadstructure.py renamed to tests/test_loadstructure.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,57 @@
55

66
import unittest
77

8+
import pytest
9+
810
from diffpy.structure import PDFFitStructure, Structure, loadStructure
911
from diffpy.structure.structureerrors import StructureFormatError
10-
from diffpy.structure.tests.testutils import datafile
1112

1213

1314
##############################################################################
1415
class TestLoadStructure(unittest.TestCase):
16+
@pytest.fixture(autouse=True)
17+
def prepare_fixture(self, datafile):
18+
self.datafile = datafile
1519

1620
def test_xcfg(self):
1721
"""check loading of atomeye xcfg format"""
18-
f = datafile("BubbleRaftShort.xcfg")
22+
f = self.datafile("BubbleRaftShort.xcfg")
1923
stru = loadStructure(f)
2024
self.assertTrue(type(stru) is Structure)
2125
self.assertRaises(StructureFormatError, loadStructure, f, "xyz")
2226
return
2327

2428
def test_discus(self):
2529
"""check loading of discus file format"""
26-
f = datafile("Ni-discus.stru")
30+
f = self.datafile("Ni-discus.stru")
2731
stru = loadStructure(f)
2832
self.assertTrue(type(stru) is PDFFitStructure)
2933
return
3034

3135
def test_cif(self):
3236
"""check loading of CIF file format"""
33-
f = datafile("PbTe.cif")
37+
f = self.datafile("PbTe.cif")
3438
stru = loadStructure(f)
3539
self.assertTrue(isinstance(stru, Structure))
3640
self.assertFalse(isinstance(stru, PDFFitStructure))
3741
return
3842

3943
def test_badfile(self):
4044
"""check loading of CIF file format"""
41-
f = datafile("Ni-bad.stru")
45+
f = self.datafile("Ni-bad.stru")
4246
self.assertRaises(StructureFormatError, loadStructure, f)
4347
return
4448

4549
def test_goodkwarg(self):
4650
"""check loading of CIF file and passing of parser keyword argument."""
47-
f = datafile("graphite.cif")
51+
f = self.datafile("graphite.cif")
4852
stru = loadStructure(f, eps=1e-10)
4953
self.assertEqual(8, len(stru))
5054
return
5155

5256
def test_badkwarg(self):
5357
"""check loading of xyz file format with invalid keyword argument"""
54-
f = datafile("bucky.xyz")
58+
f = self.datafile("bucky.xyz")
5559
self.assertRaises(TypeError, loadStructure, f, eps=1e-10)
5660
return
5761

src/diffpy/structure/tests/test_p_cif.py renamed to tests/test_p_cif.py

+16-14
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
import unittest
2020

2121
import numpy
22+
import pytest
2223

2324
from diffpy.structure import Structure
2425
from diffpy.structure.parsers import getParser
2526
from diffpy.structure.parsers.p_cif import P_cif, getSymOp, leading_float
2627
from diffpy.structure.structureerrors import StructureFormatError
27-
from diffpy.structure.tests.testutils import datafile
2828

2929
# ----------------------------------------------------------------------------
3030

@@ -65,14 +65,16 @@ def test_getSymOp(self):
6565

6666

6767
class TestP_cif(unittest.TestCase):
68-
69-
pbteciffile = datafile("PbTe.cif")
70-
badciffile = datafile("LiCl-bad.cif")
71-
graphiteciffile = datafile("graphite.cif")
72-
cdsebulkpdffitfile = datafile("CdSe_bulk.stru")
73-
teiciffile = datafile("TeI.cif")
74-
refciffile = datafile("Ni_ref.cif")
75-
places = 6
68+
@pytest.fixture(autouse=True)
69+
def prepare_fixture(self, datafile):
70+
self.datafile = datafile
71+
self.pbteciffile = datafile("PbTe.cif")
72+
self.badciffile = datafile("LiCl-bad.cif")
73+
self.graphiteciffile = datafile("graphite.cif")
74+
self.cdsebulkpdffitfile = datafile("CdSe_bulk.stru")
75+
self.teiciffile = datafile("TeI.cif")
76+
self.refciffile = datafile("Ni_ref.cif")
77+
self.places = 6
7678

7779
def setUp(self):
7880
self.ptest = P_cif()
@@ -240,7 +242,7 @@ def test_eps(self):
240242

241243
def test_unknown_occupancy(self):
242244
"test CIF file with unknown occupancy data"
243-
stru = self.ptest.parseFile(datafile("TeI-unkocc.cif"))
245+
stru = self.ptest.parseFile(self.datafile("TeI-unkocc.cif"))
244246
self.assertTrue(numpy.array_equal(16 * [1], stru.occupancy))
245247
return
246248

@@ -268,7 +270,7 @@ def test_unknown_spacegroup_number(self):
268270
def test_nosites_cif(self):
269271
"""Test reading of CIF file with no valid sites."""
270272
ptest = self.ptest
271-
stru = ptest.parseFile(datafile("nosites.cif"))
273+
stru = ptest.parseFile(self.datafile("nosites.cif"))
272274
self.assertEqual(0, len(stru))
273275
self.assertEqual(10.413, stru.lattice.a)
274276
self.assertEqual(10.413, stru.lattice.b)
@@ -278,14 +280,14 @@ def test_nosites_cif(self):
278280
def test_badspacegroup_cif(self):
279281
"""Test reading of CIF file with unrecognized space group."""
280282
ptest = self.ptest
281-
filename = datafile("badspacegroup.cif")
283+
filename = self.datafile("badspacegroup.cif")
282284
self.assertRaises(StructureFormatError, ptest.parseFile, filename)
283285
return
284286

285287
def test_custom_spacegroup_cif(self):
286288
"""Test parsing of nonstandard symops-defined space group."""
287289
pfile = self.pfile
288-
filename = datafile("customsg.cif")
290+
filename = self.datafile("customsg.cif")
289291
pfile.parseFile(filename)
290292
sg = pfile.spacegroup
291293
self.assertEqual("CIF data", sg.short_name)
@@ -363,7 +365,7 @@ def test_unknown_aniso(self):
363365
def test_curly_brace(self):
364366
"verify loading of a CIF file with unquoted curly brace"
365367
ptest = self.ptest
366-
stru = ptest.parseFile(datafile("curlybrackets.cif"))
368+
stru = ptest.parseFile(self.datafile("curlybrackets.cif"))
367369
self.assertEqual(20, len(stru))
368370
return
369371

0 commit comments

Comments
 (0)