Beispiel #1
0
 def test_from_module_import_names(self):
     self.template([
         ("from apple import ball",
          python.ImportFrom("apple", (python.alias("ball", None), ), 0)),
         ("from apple import ball as cat",
          python.ImportFrom("apple", (python.alias("ball", "cat"), ), 0)),
     ])
Beispiel #2
0
 def test_future_valid(self):
     self.template([
         ("from __future__ import with_statement",
          python.Future((python.alias("with_statement", None), ))),
         ("import __future__ as future",
          python.Import((python.alias("__future__", "future"), ))),
     ])
Beispiel #3
0
 def test_from_module_import_star(self):
     self.template([
         ("from apple import *",
          python.ImportFrom("apple", (python.alias("*", None), ), 0)),
         ("from apple.ball import *",
          python.ImportFrom("apple.ball", (python.alias("*", None), ), 0)),
     ])
Beispiel #4
0
 def test_import_module(self):
     self.template([
         (  # Single import
             "import apple", python.Import((python.alias("apple",
                                                         None), ))),
         (  # Single subpackage import
             "import apple.ball",
             python.Import((python.alias("apple.ball", None), ))),
         (  # Single alias import
             "import apple as ball",
             python.Import((python.alias("apple", "ball"), ))),
         (  # Multiple imports, 1 alias, 1 simple
             "import apple as ball, cat",
             python.Import((
                 python.alias("apple", "ball"),
                 python.alias("cat", None),
             ))),
         (  # Multiple alias imports
             "import apple as ball, cat as dog",
             python.Import((
                 python.alias("apple", "ball"),
                 python.alias("cat", "dog"),
             ))),
         (  # Multiple alias imports from subpackage
             "import apple.ball as ball, cat as dog",
             python.Import((
                 python.alias("apple.ball", "ball"),
                 python.alias("cat", "dog"),
             ))),
     ])
Beispiel #5
0
 def test_future_valid(self):
     self.template([
         (
             "from __future__ import with_statement",
             python.Future((
                 python.alias("with_statement", None),
             ))
         ),
         (
             "import __future__ as future",
             python.Import((
                 python.alias("__future__", "future"),
             ))
         ),
     ])
Beispiel #6
0
 def test_future_valid(self):
     yield from self.yield_tests(self.check_code_translation, [
         (
             "from __future__ import with_statement",
             python.Future([
                 python.alias("with_statement", None)
             ])
         ),
         (
             "import __future__ as future",
             python.Import([
                 python.alias("__future__", "future")
             ])
         ),
     ])
Beispiel #7
0
 def test_from_module_import_names(self):
     self.template([
         (
             "from apple import ball",
             python.ImportFrom(
                 "apple", (
                     python.alias("ball", None),
                 ),
                 0
             )
         ),
         (
             "from apple import ball as cat",
             python.ImportFrom(
                 "apple", (
                     python.alias("ball", "cat"),
                 ),
                 0
             )
         ),
     ])
Beispiel #8
0
 def test_from_module_import_star(self):
     self.template([
         (
             "from apple import *",
             python.ImportFrom(
                 "apple", (
                     python.alias("*", None),
                 ),
                 0
             )
         ),
         (
             "from apple.ball import *",
             python.ImportFrom(
                 "apple.ball", (
                     python.alias("*", None),
                 ),
                 0
             )
         ),
     ])
Beispiel #9
0
 def test_from_module_import_names(self):
     yield from self.yield_tests(self.check_code_translation, [
         (
             "from apple import ball",
             python.ImportFrom(
                 "apple", [
                     python.alias("ball", None)
                 ],
                 0
             )
         ),
         (
             "from apple import ball as cat",
             python.ImportFrom(
                 "apple", [
                     python.alias("ball", "cat")
                 ],
                 0
             )
         ),
     ])
Beispiel #10
0
 def test_from_module_import_star(self):
     yield from self.yield_tests(self.check_code_translation, [
         (
             "from apple import *",
             python.ImportFrom(
                 "apple", [
                     python.alias("*", None)
                 ],
                 0
             )
         ),
         (
             "from apple.ball import *",
             python.ImportFrom(
                 "apple.ball", [
                     python.alias("*", None)
                 ],
                 0
             )
         ),
     ])
Beispiel #11
0
 def test_import_module(self):
     self.template([
         (  # Single import
             "import apple",
             python.Import((
                 python.alias("apple", None),
             ))
         ),
         (  # Single subpackage import
             "import apple.ball",
             python.Import((
                 python.alias("apple.ball", None),
             ))
         ),
         (  # Single alias import
             "import apple as ball",
             python.Import((
                 python.alias("apple", "ball"),
             ))
         ),
         (  # Multiple imports, 1 alias, 1 simple
             "import apple as ball, cat",
             python.Import((
                 python.alias("apple", "ball"),
                 python.alias("cat", None),
             ))
         ),
         (  # Multiple alias imports
             "import apple as ball, cat as dog",
             python.Import((
                 python.alias("apple", "ball"),
                 python.alias("cat", "dog"),
             ))
         ),
         (  # Multiple alias imports from subpackage
             "import apple.ball as ball, cat as dog",
             python.Import((
                 python.alias("apple.ball", "ball"),
                 python.alias("cat", "dog"),
             ))
         ),
     ])
Beispiel #12
0
 def test_import_module(self):
     yield from self.yield_tests(self.check_code_translation, [
         (  # Single import
             "import apple",
             python.Import([
                 python.alias("apple", None),
             ])
         ),
         (  # Single subpackage import
             "import apple.ball",
             python.Import([
                 python.alias("apple.ball", None),
             ])
         ),
         (  # Single alias import
             "import apple as ball",
             python.Import([
                 python.alias("apple", "ball"),
             ])
         ),
         (  # Multiple imports, 1 alias, 1 simple
             "import apple as ball, cat",
             python.Import([
                 python.alias("apple", "ball"),
                 python.alias("cat", None),
             ])
         ),
         (  # Multiple alias imports
             "import apple as ball, cat as dog",
             python.Import([
                 python.alias("apple", "ball"),
                 python.alias("cat", "dog"),
             ])
         ),
         (  # Multiple alias imports from subpackage
             "import apple.ball as ball, cat as dog",
             python.Import([
                 python.alias("apple.ball", "ball"),
                 python.alias("cat", "dog"),
             ])
         ),
     ])
Beispiel #13
0
 def test_from_submodule_import_names(self):
     self.template([
         (
             "from apple.ball import (\n    cat, \n    dog,)",
             python.ImportFrom(
                 "apple.ball",
                 (
                     python.alias("cat", None),
                     python.alias("dog", None),
                 ),
                 0
             )
         ),
         (
             "from apple.ball import cat as dog",
             python.ImportFrom(
                 "apple.ball",
                 (
                     python.alias("cat", "dog"),
                 ),
                 0
             )
         ),
         (
             "from apple.ball import cat as dog, egg",
             python.ImportFrom(
                 "apple.ball",
                 (
                     python.alias("cat", "dog"),
                     python.alias("egg", None),
                 ),
                 0
             )
         ),
         (
             "from apple.ball import (\n    cat as dog, \n    egg as frog)",
             python.ImportFrom(
                 "apple.ball",
                 (
                     python.alias("cat", "dog"),
                     python.alias("egg", "frog"),
                 ),
                 0
             )
         ),
     ])
Beispiel #14
0
 def test_from_submodule_import_names(self):
     yield from self.yield_tests(self.check_code_translation, [
         (
             "from apple.ball import (\n    cat, \n    dog,)",
             python.ImportFrom(
                 "apple.ball",
                 [
                     python.alias("cat", None),
                     python.alias("dog", None),
                 ],
                 0
             )
         ),
         (
             "from apple.ball import cat as dog",
             python.ImportFrom(
                 "apple.ball",
                 [
                     python.alias("cat", "dog")
                 ],
                 0
             )
         ),
         (
             "from apple.ball import cat as dog, egg",
             python.ImportFrom(
                 "apple.ball",
                 [
                     python.alias("cat", "dog"),
                     python.alias("egg", None),
                 ],
                 0
             )
         ),
         (
             "from apple.ball import (\n    cat as dog, \n    egg as frog)",
             python.ImportFrom(
                 "apple.ball",
                 [
                     python.alias("cat", "dog"),
                     python.alias("egg", "frog"),
                 ],
                 0
             )
         ),
     ])