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
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
python_files = test*.py
2 changes: 1 addition & 1 deletion src/diffpy/pdfgui/control/pdfguicontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def run(self):

def startQueue(self):
"""start queue manager"""
self.queueManager.setDaemon(True)
self.queueManager.ddaemon = True
self.queueManager.start()

def checkQueue(self):
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/pdfgui/gui/aboutdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import wx.lib.agw.hyperlink

from diffpy.pdfgui.gui.pdfguiglobals import iconpath
from diffpy.pdfgui.version import __date__, __version__
from diffpy.pdfgui.version import __version__, __year__

_acknowledgement = """\
This software was developed by the Billinge-group as part of the Distributed
Expand All @@ -42,7 +42,7 @@
computer programs for studying nanostructure in crystals,
J. Phys.: Condens. Matter 19, 335219 (2007)."""

_copyright = "(c) 2005-{year},".format(year=__date__[:4])
_copyright = "(c) 2005-{year},".format(year=__year__)

_homepage = "https://www.diffpy.org"

Expand Down
9 changes: 6 additions & 3 deletions src/diffpy/pdfgui/gui/extendedplotframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,11 @@ def insertCurve(self, xData, yData, style):
return: internal reference to the newly added curve
"""
stylestr, properties = self.__translateStyles(style)
curveRef = self.subplot.plot(xData, yData, stylestr, **properties)[0]
self.subplot.legend(**legendBoxProperties())
if stylestr == "": # blank stylestring throws warning for duplicated information
curveRef = self.subplot.plot(xData, yData, **properties)[0]
else:
curveRef = self.subplot.plot(xData, yData, stylestr, **properties)[0]
self.subplot.legend([], **legendBoxProperties()) # add blank list argument to prevent warning
try:
self.datalims[curveRef] = (min(xData), max(xData), min(yData), max(yData))
except ValueError:
Expand Down Expand Up @@ -314,7 +317,7 @@ def __translateStyles(self, style):
# not 'points', so line properties are required as well
lineStyle = lineStyleDict.get(style["line"], "-") # prefer solid
lineWidth = style["width"]
stylestr += lineStyle
# stylestr += lineStyle # no need to add lineStyle to stylestr when in properties
properties.update({"color": color, "linestyle": lineStyle, "linewidth": lineWidth})

if "legend" in style:
Expand Down
19 changes: 11 additions & 8 deletions src/diffpy/pdfgui/gui/pdfguiglobals.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import os.path

from pkg_resources import Requirement, resource_filename
from importlib_resources import as_file, files

from diffpy.pdfgui.gui import debugoptions

Expand All @@ -31,14 +31,15 @@
isAltered = False

# Resolve APPDATADIR base path to application data files.
_mydir = os.path.abspath(resource_filename(__name__, ""))
_upbasedir = os.path.normpath(_mydir + "/../../..")
_development_mode = os.path.basename(_upbasedir) == "src" and os.path.isfile(
os.path.join(_upbasedir, "../setup.py")
)
with as_file(files(__name__)) as file:
_mydir = os.path.abspath(file)
_upbasedir = os.path.normpath(_mydir + "/../../..")
_development_mode = os.path.basename(_upbasedir) == "src" and os.path.isfile(
os.path.join(_upbasedir, "../setup.py")
)

# Requirement must have egg-info. Do not use in _development_mode.
_req = Requirement.parse("diffpy.pdfgui")
_req = "diffpy.pdfgui"

# pavol
# APPDATADIR = (os.path.dirname(_upbasedir) if _development_mode
Expand All @@ -47,9 +48,11 @@
if _development_mode:
APPDATADIR = os.path.dirname(_mydir)
else:
APPDATADIR = os.path.join(resource_filename(_req, ""), "diffpy/pdfgui")
with as_file(files(_req)) as file:
APPDATADIR = os.path.join(file, "")

APPDATADIR = os.path.abspath(APPDATADIR)
print(APPDATADIR)

# Location of the HTML manual
docMainFile = os.path.join(APPDATADIR, "doc/manual/pdfgui.html")
Expand Down
47 changes: 24 additions & 23 deletions src/diffpy/pdfgui/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,32 @@ def testsuite(pattern=""):
from itertools import chain
from os.path import dirname

from pkg_resources import resource_filename
from importlib_resources import as_file, files

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, 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
ref = files(__name__)
with as_file(ref) as thisdir:
depth = __name__.count(".") + 1
topdir = thisdir
for i in range(depth):
topdir = dirname(topdir)
suite_all = loader.discover(thisdir, 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():
Expand Down
8 changes: 7 additions & 1 deletion src/diffpy/pdfgui/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@
# We do not use the other three variables, but can be added back if needed.
# __all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"]

# from importlib_resources import files, as_file
import os
import time

# obtain version information
from importlib.metadata import version
from importlib.metadata import distribution, version

# with as_file(distribution("diffpy.pdfgui")) as file:
__year__ = time.ctime(os.path.getctime(distribution("diffpy.pdfgui")._path))[-4:]
__version__ = version("diffpy.pdfgui")

# End of file