def test_is_shebang_comment(self):
        """
        Tests whether the fixer_util.is_encoding_comment() function is working.
        """
        shebang_comments = [u"#!/usr/bin/env python\n" u"#!/usr/bin/python2\n", u"#! /usr/bin/python3\n"]
        not_shebang_comments = [u"# I saw a giant python\n", u"# I have never seen a python2\n"]
        for comment in shebang_comments:
            node = FromImport(u"math", [Leaf(token.NAME, u"cos", prefix=" ")])
            node.prefix = comment
            self.assertTrue(is_shebang_comment(node))

        for comment in not_shebang_comments:
            node = FromImport(u"math", [Leaf(token.NAME, u"cos", prefix=" ")])
            node.prefix = comment
            self.assertFalse(is_shebang_comment(node))
Exemple #2
0
 def test_is_shebang_comment(self):
     """
     Tests whether the libfuturize.fixer_util.is_shebang_comment() function is working
     """
     node = FromImport(u'math', [Leaf(token.NAME, u'cos', prefix=" ")])
     node.prefix = u'#!/usr/bin/env python\n'
     self.assertTrue(is_shebang_comment(node))
Exemple #3
0
 def test_is_shebang_comment(self):
     """
     Tests whether the libfuturize.fixer_util.is_shebang_comment() function is working
     """
     node = FromImport(u'math', [Leaf(token.NAME, u'cos', prefix=" ")])
     node.prefix = u'#!/usr/bin/env python\n'
     self.assertTrue(is_shebang_comment(node))
Exemple #4
0
    def test_is_shebang_comment(self):
        """
        Tests whether the fixer_util.is_encoding_comment() function is working.
        """
        shebang_comments = [u'#!/usr/bin/env python\n'
                             u"#!/usr/bin/python2\n",
                             u"#! /usr/bin/python3\n",
                            ]
        not_shebang_comments = [u"# I saw a giant python\n",
                                 u"# I have never seen a python2\n",
                               ]
        for comment in shebang_comments:
            node = FromImport(u'math', [Leaf(token.NAME, u'cos', prefix=" ")])
            node.prefix = comment
            self.assertTrue(is_shebang_comment(node))

        for comment in not_shebang_comments:
            node = FromImport(u'math', [Leaf(token.NAME, u'cos', prefix=" ")])
            node.prefix = comment
            self.assertFalse(is_shebang_comment(node))