Skip to content

Commit

Permalink
BUG #182 avoid import plugins here
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Jul 22, 2019
1 parent 9a3beaf commit 073e3f6
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions tests/test_uxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
sys.path.insert(0, _path)
sys.path.insert(0, _test_path)

import spec2nexus
from spec2nexus import writer
from spec2nexus.spec import SpecDataFile, SpecDataFileScan

from spec2nexus.plugins.uxml import UXML_metadata, UXML_Error

SPEC_DATA_FILE_LINES = """
#UXML <group name="attenuator1" NX_class="NXattenuator" number="1" pv_prefix="33idd:filter:Fi1:" unique_id="33idd:filter:Fi1:">
Expand All @@ -44,10 +44,9 @@
"""

def get_paths():
import spec2nexus.plugins
uxml_path = os.path.abspath(os.path.dirname(spec2nexus.plugins.__file__))
basepath = os.path.join(uxml_path, '..')
return basepath, uxml_path
_p = os.path.abspath(os.path.dirname(writer.__file__))
uxml_path = os.path.join(_p, 'plugins')
return _p, uxml_path


class TestPlugin(unittest.TestCase):
Expand All @@ -64,8 +63,8 @@ def test_process(self):
self.assertTrue(isinstance(self.scan, SpecDataFileScan))

# test create instance
uxml = UXML_metadata()
self.assertTrue(isinstance(uxml, UXML_metadata))
uxml = spec2nexus.plugins.uxml.UXML_metadata()
self.assertTrue(isinstance(uxml, spec2nexus.plugins.uxml.UXML_metadata))

# test that specific attributes not yet defined
txt = 'this is text'
Expand All @@ -84,7 +83,7 @@ def test_parse(self):
"""test that UXML lines are parsed"""

self.scan = SpecDataFileScan(None, '')
uxml = UXML_metadata()
uxml = spec2nexus.plugins.uxml.UXML_metadata()
for line in SPEC_DATA_FILE_LINES.strip().splitlines():
txt = line.strip()
if len(txt) > 0:
Expand All @@ -99,7 +98,7 @@ def test_parse(self):
def test_postprocess(self):
"""test the :meth:`postprocess` method"""
self.scan = SpecDataFileScan(None, '')
uxml = UXML_metadata()
uxml = spec2nexus.plugins.uxml.UXML_metadata()
for line in SPEC_DATA_FILE_LINES.strip().splitlines():
txt = line.strip()
if len(txt) > 0:
Expand All @@ -125,7 +124,7 @@ def test_postprocess(self):
def test_writer(self):
"""test the :meth:`writer` method"""
self.scan = SpecDataFileScan(None, '')
uxml = UXML_metadata()
uxml = spec2nexus.plugins.uxml.UXML_metadata()
for line in SPEC_DATA_FILE_LINES.strip().splitlines():
txt = line.strip()
if len(txt) > 0:
Expand Down Expand Up @@ -160,7 +159,7 @@ def testName(self):
self.assertTrue(isinstance(spec_data, SpecDataFile))
scan = spec_data.getScan(1)

with self.assertRaises(UXML_Error) as context:
with self.assertRaises(spec2nexus.plugins.uxml.UXML_Error) as context:
scan.interpret()
received = str(context.exception)
expected = "UXML error: Element 'group': "
Expand Down

0 comments on commit 073e3f6

Please sign in to comment.