Skip to content

Commit

Permalink
TST #306 test for deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed May 6, 2020
1 parent 3022872 commit bbabd98
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apstools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,12 @@ def listobjects(show_pv=True, printing=True, verbose=False, symbols=None):
return table


def show_ophyd_objects(show_pv=True,
def show_ophyd_symbols(show_pv=True,
printing=True,
verbose=False,
symbols=None):
warnings.warn(
"DEPRECATED: show_ophyd_objects() will be removed"
"DEPRECATED: show_ophyd_symbols() will be removed"
" in a future release. Use listobjects() instead."
)
listobjects(
Expand Down
18 changes: 16 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
import time
import unittest
import warnings

_path = os.path.join(os.path.dirname(__file__), '..')
if _path not in sys.path:
Expand Down Expand Up @@ -167,13 +168,13 @@ def test_trim_string_for_EPICS(self):
expected = source[:APS_utils.MAX_EPICS_STRINGOUT_LENGTH-1]
self.assertEqual(received, expected)

def test_show_ophyd_symbols(self):
def test_listobjects(self):
sims = ophyd.sim.hw().__dict__
wont_show = ("flyer1", "flyer2", "new_trivial_flyer", "trivial_flyer")
num = len(sims) - len(wont_show)
kk = sorted(sims.keys())
# sims hardware not found by show_ophyd_symbols() in globals!
table = APS_utils.show_ophyd_symbols(symbols=sims, printing=False)
table = APS_utils.listobjects(symbols=sims, printing=False)
self.assertEqual(4, len(table.labels))
rr = [r[0] for r in table.rows]
for k in kk:
Expand All @@ -182,6 +183,19 @@ def test_show_ophyd_symbols(self):
self.assertTrue(k in rr, msg)
self.assertEqual(num, len(table.rows))

def test_show_ophyd_symbols(self):
sims = ophyd.sim.hw().__dict__
wont_show = ("flyer1", "flyer2", "new_trivial_flyer", "trivial_flyer")
num = len(sims) - len(wont_show)
kk = sorted(sims.keys())
# sims hardware not found by show_ophyd_symbols() in globals!
with warnings.catch_warnings(record=True) as w:
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
table = APS_utils.show_ophyd_symbols(symbols=sims, printing=False)
assert len(w) == 1
assert "DEPRECATED" in str(w[-1].message)

def test_unix(self):
cmd = 'echo "hello"'
out, err = APS_utils.unix(cmd)
Expand Down

0 comments on commit bbabd98

Please sign in to comment.