def test_view_file(self): test_dir = os.path.dirname(__file__) testfile = os.path.join(test_dir, 'test_textview.py') view = tv.view_file(root, 'Title', testfile, modal=False) self.assertIsInstance(view, tv.TextViewer) self.assertIn('Test', view.textView.get('1.0', '1.end')) view.Ok() # Mock messagebox will be used and view_file will not return anything testfile = os.path.join(test_dir, '../notthere.py') view = tv.view_file(root, 'Title', testfile, modal=False) self.assertIsNone(view)
def test_bad_encoding(self): p = os.path fn = p.abspath(p.join(p.dirname(__file__), '..', 'CREDITS.txt')) tv.showerror.title = None view = tv.view_file(root, 'Title', fn, 'ascii', modal=False) self.assertIsNone(view) self.assertEqual(tv.showerror.title, 'Unicode Decode Error')
def test_view_file(self): view = tv.view_file(root, 'Title', __file__, modal=False) self.assertIsInstance(view, tv.ViewWindow) self.assertIsInstance(view.viewframe, tv.ViewFrame) get = view.viewframe.textframe.text.get self.assertIn('Test', get('1.0', '1.end')) view.ok()
def display_file_text(self, title, filename, encoding=None): fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), filename) self._current_textview = textview.view_file(self, title, fn, encoding, _utest=self._utest)
def _command(): self.called = True self.view = tv.view_file(root, 'TITLE_FILE', __file__, encoding='ascii', _utest=True)
def test_view_file(self): view = tv.view_file(root, 'Title', __file__, 'ascii', modal=False) self.assertIsInstance(view, tv.ViewWindow) self.assertIsInstance(view.viewframe, tv.ViewFrame) get = view.viewframe.textframe.text.get self.assertIn('Test', get('1.0', '1.end')) view.ok()
def display_file_text(self, title, filename, encoding=None): """Create textview for filename. The filename needs to be in the current directory. The path is sent to a text viewer with self as the parent, title as the title of the popup, and the file encoding. """ fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), filename) self._current_textview = textview.view_file( self, title, fn, encoding, _utest=self._utest)
def _command(): self.called = True self.view = tv.view_file(root, 'TITLE_FILE', __file__, _utest=True)
def display_file_text(self, title, filename, encoding=None): fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), filename) textview.view_file(self, title, fn, encoding)
def test_view_file(self): view = tv.view_file(root, 'Title', __file__, modal=False) self.assertIsInstance(view, tv.TextViewer) self.assertIn('Test', view.text.get('1.0', '1.end')) view.ok()
def test_view_file(self): view = tv.view_file(root, 'Title', __file__, modal=False) self.assertIsInstance(view, tv.TextViewer) self.assertIn('Test', view.textView.get('1.0', '1.end')) view.Ok()
def test_bad_file(self): # Mock showerror will be used; view_file will return None. view = tv.view_file(root, 'Title', 'abc.xyz', modal=False) self.assertIsNone(view) self.assertEqual(tv.showerror.title, 'File Load Error')
def test_bad_file(self): view = tv.view_file(root, 'Title', 'abc.xyz', modal=False) self.assertIsNone(view) self.assertEqual(tv.showerror.title, 'File Load Error')