Skip to content
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
23 changes: 23 additions & 0 deletions news/folder.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:**

* tests folder at the root of the repo

**Security:**

* <news item>
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dirty_template = "{tag}"
[tool.setuptools.packages.find]
where = ["src"] # list of folders that contain the packages (["."] by default)
include = ["*"] # package names should match these glob patterns (["*"] by default)
exclude = ["diffpy.structure.tests*"] # exclude packages matching these glob patterns (empty by default)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave this in but with an empty list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it - done.

exclude = [] # exclude packages matching these glob patterns (empty by default)
namespaces = false # to disable scanning PEP 420 namespaces (true by default)

[tool.setuptools.dynamic]
Expand Down
77 changes: 0 additions & 77 deletions src/diffpy/structure/tests/__init__.py

This file was deleted.

35 changes: 0 additions & 35 deletions src/diffpy/structure/tests/debug.py

This file was deleted.

36 changes: 0 additions & 36 deletions src/diffpy/structure/tests/run.py

This file was deleted.

25 changes: 0 additions & 25 deletions src/diffpy/structure/tests/testutils.py

This file was deleted.

10 changes: 10 additions & 0 deletions src/diffpy/structure/tests/conftest.py → tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ 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
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,57 @@

import unittest

import pytest

from diffpy.structure import PDFFitStructure, Structure, loadStructure
from diffpy.structure.structureerrors import StructureFormatError
from diffpy.structure.tests.testutils import datafile


##############################################################################
class TestLoadStructure(unittest.TestCase):
@pytest.fixture(autouse=True)
def prepare_fixture(self, datafile):
self.datafile = datafile

def test_xcfg(self):
"""check loading of atomeye xcfg format"""
f = datafile("BubbleRaftShort.xcfg")
f = self.datafile("BubbleRaftShort.xcfg")
stru = loadStructure(f)
self.assertTrue(type(stru) is Structure)
self.assertRaises(StructureFormatError, loadStructure, f, "xyz")
return

def test_discus(self):
"""check loading of discus file format"""
f = datafile("Ni-discus.stru")
f = self.datafile("Ni-discus.stru")
stru = loadStructure(f)
self.assertTrue(type(stru) is PDFFitStructure)
return

def test_cif(self):
"""check loading of CIF file format"""
f = datafile("PbTe.cif")
f = self.datafile("PbTe.cif")
stru = loadStructure(f)
self.assertTrue(isinstance(stru, Structure))
self.assertFalse(isinstance(stru, PDFFitStructure))
return

def test_badfile(self):
"""check loading of CIF file format"""
f = datafile("Ni-bad.stru")
f = self.datafile("Ni-bad.stru")
self.assertRaises(StructureFormatError, loadStructure, f)
return

def test_goodkwarg(self):
"""check loading of CIF file and passing of parser keyword argument."""
f = datafile("graphite.cif")
f = self.datafile("graphite.cif")
stru = loadStructure(f, eps=1e-10)
self.assertEqual(8, len(stru))
return

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

Expand Down
File renamed without changes.
30 changes: 16 additions & 14 deletions src/diffpy/structure/tests/test_p_cif.py → tests/test_p_cif.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import unittest

import numpy
import pytest

from diffpy.structure import Structure
from diffpy.structure.parsers import getParser
from diffpy.structure.parsers.p_cif import P_cif, getSymOp, leading_float
from diffpy.structure.structureerrors import StructureFormatError
from diffpy.structure.tests.testutils import datafile

# ----------------------------------------------------------------------------

Expand Down Expand Up @@ -65,14 +65,16 @@ def test_getSymOp(self):


class TestP_cif(unittest.TestCase):

pbteciffile = datafile("PbTe.cif")
badciffile = datafile("LiCl-bad.cif")
graphiteciffile = datafile("graphite.cif")
cdsebulkpdffitfile = datafile("CdSe_bulk.stru")
teiciffile = datafile("TeI.cif")
refciffile = datafile("Ni_ref.cif")
places = 6
@pytest.fixture(autouse=True)
def prepare_fixture(self, datafile):
self.datafile = datafile
self.pbteciffile = datafile("PbTe.cif")
self.badciffile = datafile("LiCl-bad.cif")
self.graphiteciffile = datafile("graphite.cif")
self.cdsebulkpdffitfile = datafile("CdSe_bulk.stru")
self.teiciffile = datafile("TeI.cif")
self.refciffile = datafile("Ni_ref.cif")
self.places = 6

def setUp(self):
self.ptest = P_cif()
Expand Down Expand Up @@ -240,7 +242,7 @@ def test_eps(self):

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

Expand Down Expand Up @@ -268,7 +270,7 @@ def test_unknown_spacegroup_number(self):
def test_nosites_cif(self):
"""Test reading of CIF file with no valid sites."""
ptest = self.ptest
stru = ptest.parseFile(datafile("nosites.cif"))
stru = ptest.parseFile(self.datafile("nosites.cif"))
self.assertEqual(0, len(stru))
self.assertEqual(10.413, stru.lattice.a)
self.assertEqual(10.413, stru.lattice.b)
Expand All @@ -278,14 +280,14 @@ def test_nosites_cif(self):
def test_badspacegroup_cif(self):
"""Test reading of CIF file with unrecognized space group."""
ptest = self.ptest
filename = datafile("badspacegroup.cif")
filename = self.datafile("badspacegroup.cif")
self.assertRaises(StructureFormatError, ptest.parseFile, filename)
return

def test_custom_spacegroup_cif(self):
"""Test parsing of nonstandard symops-defined space group."""
pfile = self.pfile
filename = datafile("customsg.cif")
filename = self.datafile("customsg.cif")
pfile.parseFile(filename)
sg = pfile.spacegroup
self.assertEqual("CIF data", sg.short_name)
Expand Down Expand Up @@ -363,7 +365,7 @@ def test_unknown_aniso(self):
def test_curly_brace(self):
"verify loading of a CIF file with unquoted curly brace"
ptest = self.ptest
stru = ptest.parseFile(datafile("curlybrackets.cif"))
stru = ptest.parseFile(self.datafile("curlybrackets.cif"))
self.assertEqual(20, len(stru))
return

Expand Down
Loading