Skip to content

Commit

Permalink
Remove usages of unittest2
Browse files Browse the repository at this point in the history
Refs #179
  • Loading branch information
berkerpeksag committed Jan 1, 2025
1 parent 4f0c684 commit 5cd679f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 35 deletions.
5 changes: 1 addition & 4 deletions tests/check_astunparse.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import ast

try:
import unittest2 as unittest
except ImportError:
import unittest
import unittest

from . import test_code_gen

Expand Down
6 changes: 1 addition & 5 deletions tests/test_code_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
import math
import sys
import textwrap

try:
import unittest2 as unittest
except ImportError:
import unittest
import unittest

import astor

Expand Down
5 changes: 1 addition & 4 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import ast
import sys
import unittest
import warnings
try:
import unittest2 as unittest
except ImportError:
import unittest

import astor

Expand Down
28 changes: 11 additions & 17 deletions tests/test_optional.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,25 @@
"""

try:
import unittest2 as unittest
except ImportError:
import unittest
import unittest

try:
from test_code_gen import Comparisons
except ImportError:
from .test_code_gen import Comparisons
from .test_code_gen import Comparisons

try:
from astunparse_common import AstunparseCommonTestCase
except ImportError:
AstunparseCommonTestCase = None
AstunparseCommonTestCase = object


@unittest.skipIf(AstunparseCommonTestCase is object, "requires astunparse")
class UnparseTestCase(unittest.TestCase, Comparisons, AstunparseCommonTestCase):

if AstunparseCommonTestCase is not None:
def check_roundtrip(self, code1, mode=None):
self.assertAstRoundtrips(code1)

class UnparseTestCase(AstunparseCommonTestCase, unittest.TestCase,
Comparisons):

def check_roundtrip(self, code1, mode=None):
self.assertAstRoundtrips(code1)
def test_files(self):
""" Don't bother -- we do this manually and more thoroughly """

def test_files(self):
""" Don't bother -- we do this manually and more thoroughly """

if __name__ == '__main__':
unittest.main()
6 changes: 1 addition & 5 deletions tests/test_rtrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
"""

import os

try:
import unittest2 as unittest
except ImportError:
import unittest
import unittest

import astor.rtrip

Expand Down

0 comments on commit 5cd679f

Please sign in to comment.