Skip to content

Commit

Permalink
Python v3 (#55)
Browse files Browse the repository at this point in the history
* Per 'http://python-future.org/automatic_conversion.html' py2 & py3 compatibility.

* Make sure test fails if there is more than one list entry.

* Fix deprecated warning for invalid escapes.

* Support utf-8 in template files

* Add utf-8 characters to a test example

* Unicode example in template input.

* Switch to utf-8 strings and remove unnecessary conversions.

* Remove legacy lint checks

* Migrate StringIO and remove unneeded import six.

* Remove unnecessary explicit unicast declaration.

* oll back changes to 'open'.

* Cosmetic linting.

* Package 'future' needed for importing builtins.
[aliases]
test=pytest

* Add tests and testdata to distribution.

* Use correct install_requires stanza for dependencies.

* Include testdata files in binarty dist for tyesting.
  • Loading branch information
harro authored Jul 25, 2019
1 parent 5d5f63a commit ac90235
Show file tree
Hide file tree
Showing 14 changed files with 234 additions and 141 deletions.
5 changes: 4 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
include README.md
include COPYING
include *.md
include *.txt
recursive-include tests *.py
recursive-include examples *
recursive-include testdata *
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ description-file = README.md

[aliases]
test=pytest

[bdist_wheel]
universal=1
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Software Development :: Libraries'],
requires=['six'],
packages=['textfsm'],
include_package_data=True,
package_data={'textfsm': ['../testdata/*']},
install_requires=['six', 'future'],
setup_requires=['pytest-runner'],
tests_require=['pytest'])
4 changes: 3 additions & 1 deletion tests/clitable_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import copy
import os
import re
import unittest

from io import StringIO
from textfsm import clitable
from textfsm import copyable_regex_object
from six.moves import StringIO


class UnitTestIndexTable(unittest.TestCase):
Expand Down Expand Up @@ -88,6 +89,7 @@ class UnitTestCliTable(unittest.TestCase):
"""Tests the CliTable class."""

def setUp(self):
super(UnitTestCliTable, self).setUp()
clitable.CliTable.INDEX = {}
self.clitable = clitable.CliTable('default_index', 'testdata')
self.input_data = ('a b c\n'
Expand Down
1 change: 1 addition & 0 deletions tests/copyable_regex_object_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import copy
import unittest
Expand Down
10 changes: 8 additions & 2 deletions tests/terminal_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,23 @@

"""Unittest for terminal module."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from builtins import range
from builtins import object
import sys
import unittest

# pylint: disable=redefined-builtin
from six.moves import range
from textfsm import terminal


class TerminalTest(unittest.TestCase):

def setUp(self):
super(TerminalTest, self).setUp()
self.environ_orig = terminal.os.environ
self.open_orig = terminal.os.open
self.terminal_orig = terminal.TerminalSize
Expand Down Expand Up @@ -142,6 +147,7 @@ def flush(self):
class PagerTest(unittest.TestCase):

def setUp(self):
super(PagerTest, self).setUp()
sys.stdout = FakeTerminal()
self.get_ch_orig = terminal.Pager._GetCh
terminal.Pager._GetCh = lambda self: 'q'
Expand Down
Loading

0 comments on commit ac90235

Please sign in to comment.