New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mission "clean test logs" - handles all kind of userwarnings/deprecation warnings #1888

Merged
merged 21 commits into from Sep 22, 2017
Commits
Jump to file or symbol
Failed to load files and symbols.
+10 −3
Diff settings

Always

Just for now

Viewing a subset of changes. View all

catches a UserWarning

  • Loading branch information...
barsch authored and krischer committed Sep 13, 2017
commit 83afbca6172a23bf087681d125b16016b2158e82
@@ -69,9 +69,9 @@ def test_read_sac_byteorder(self):
A read should fail if the byteorder is wrong
"""
with self.assertRaises(IOError):
sac = SACTrace.read(self.filebe, byteorder='little')
SACTrace.read(self.filebe, byteorder='little')
with self.assertRaises(IOError):
sac = SACTrace.read(self.file, byteorder='big')
SACTrace.read(self.file, byteorder='big')
# a SACTrace should show the correct byteorder
sac = SACTrace.read(self.filebe, byteorder='big')
self.assertEqual(sac.byteorder, 'big')
@@ -373,7 +373,14 @@ def test_string_headers(self):
# get/set value too long
too_long = "{}_1234567890".format(hdr)
setattr(sac, hdr, too_long)
# will raise "UserWarning: Alphanumeric headers longer than 8
# characters are right-truncated"
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always', UserWarning)
setattr(sac, hdr, too_long)
self.assertEqual(len(w), 1)
self.assertEqual(w[0].category, UserWarning)
self.assertIn('Alphanumeric headers longer than 8', str(w[0]))
self.assertEqual(sac._hs[_hd.STRHDRS.index(hdr)].decode(),
too_long[:8])
self.assertEqual(getattr(sac, hdr), too_long[:8].strip())
ProTip! Use n and p to navigate between commits in a pull request.