Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
 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')
Ejemplo n.º 3
0
 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')
Ejemplo n.º 4
0
 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()
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 def _command():
     self.called = True
     self.view = tv.view_file(root,
                              'TITLE_FILE',
                              __file__,
                              encoding='ascii',
                              _utest=True)
Ejemplo n.º 7
0
 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()
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
    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)
Ejemplo n.º 10
0
 def _command():
     self.called = True
     self.view = tv.view_file(root, 'TITLE_FILE', __file__, _utest=True)
Ejemplo n.º 11
0
 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)
Ejemplo n.º 12
0
 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)
Ejemplo n.º 13
0
 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()
Ejemplo n.º 14
0
 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()
Ejemplo n.º 15
0
 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')
Ejemplo n.º 16
0
 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')
Ejemplo n.º 17
0
 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')