commit 7eb3ff2b705e0fa0419b892b4d2b1128c91e2c0e Author: Damian Johnson <ata...@torproject.org> Date: Fri Apr 1 11:01:04 2016 -0700
Unit test join() util Just some quick tests for our join() utility. Really tempted to drop this function since it's soley used by the graph and log panels but not nice alternative isn't coming to mind. :/ --- test/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/__init__.py b/test/__init__.py index 05acdaa..e64593c 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -4,7 +4,7 @@ Unit tests for nyx. import unittest -from nyx import expand_path, uses_settings +from nyx import expand_path, join, uses_settings from mock import patch, Mock @@ -31,3 +31,14 @@ class TestBaseUtil(unittest.TestCase): self.assertEqual('/chroot/your_cwd/torrc', expand_path('torrc')) config.set('tor.chroot', None) + + def test_join(self): + # check our pydoc examples + + self.assertEqual('This is a looooong', join(['This', 'is', 'a', 'looooong', 'message'], size = 18)) + self.assertEqual('This is a', join(['This', 'is', 'a', 'looooong', 'message'], size = 17)) + self.assertEqual('', join(['This', 'is', 'a', 'looooong', 'message'], size = 2)) + + # include a joining character + + self.assertEqual('Download: 5 MB, Upload: 3 MB', join(['Download: 5 MB', 'Upload: 3 MB', 'Other: 2 MB'], ', ', 30)) _______________________________________________ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits