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

Lines changed: 23 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/diffpy/structure/tests/debug.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/diffpy/structure/tests/run.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/diffpy/structure/tests/testutils.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

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

Lines changed: 10 additions & 0 deletions
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

Lines changed: 11 additions & 7 deletions
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

0 commit comments

Comments
 (0)