Ejemplo n.º 1
0
    def test_main_dash_m_with_mock_stdin(self):
        from slimit.minifier import main

        out = StringIO.StringIO()
        inp = StringIO.StringIO("var global = 5;")
        main(["-m"], inp=inp, out=out)
        self.assertEqual("var a=5;", out.getvalue())
Ejemplo n.º 2
0
    def test_main_sys_argv(self):
        out = io.StringIO()
        inp = io.StringIO('var global = 5;')
        with redirected_sys_argv(['slimit', '-m', '-t']):
            from slimit.minifier import main
            main(inp=inp, out=out)

        self.assertEqual('var a=5;', out.getvalue())
Ejemplo n.º 3
0
    def test_main_sys_argv(self):
        out = StringIO.StringIO()
        inp = StringIO.StringIO('var global = 5;')
        with redirected_sys_argv(['slimit', '-m', '-t']):
            from slimit.minifier import main
            main(inp=inp, out=out)

        self.assertEqual('var a=5;', out.getvalue())
Ejemplo n.º 4
0
    def test_main_sys_argv(self):
        out = StringIO.StringIO()
        inp = StringIO.StringIO("var global = 5;")
        with redirected_sys_argv(["slimit", "-m"]):
            from slimit.minifier import main

            main(inp=inp, out=out)

        self.assertEqual("var a=5;", out.getvalue())
Ejemplo n.º 5
0
    def test_main_stdin_stdout(self):
        # slimit.minifier should be deleted from sys.modules in order
        # to have a proper reference to sys.stdin and sys.stdou when
        # 'main' definition is evaluated during module import
        try:
            del sys.modules['slimit.minifier']
        except KeyError:
            pass

        with redirected_input_output(input='var global = 5;') as out:
            from slimit.minifier import main
            main(['-m'])

        self.assertEqual('var a=5;', out.getvalue())
Ejemplo n.º 6
0
    def test_main_stdin_stdout(self):
        # slimit.minifier should be deleted from sys.modules in order
        # to have a proper reference to sys.stdin and sys.stdou when
        # 'main' definition is evaluated during module import
        try:
            del sys.modules["slimit.minifier"]
        except KeyError:
            pass

        with redirected_input_output(input="var global = 5;") as out:
            from slimit.minifier import main

            main(["-m"])

        self.assertEqual("var a=5;", out.getvalue())
Ejemplo n.º 7
0
    def test_main_stdin_stdout(self):
        # slimit.minifier should be deleted from sys.modules in order
        # to have a proper reference to sys.stdin and sys.stdou when
        # 'main' definition is evaluated during module import
        old_module = None
        try:
            old_module = sys.modules.pop('slimit.minifier')
        except KeyError:
            pass

        with redirected_input_output(
            input='function foo() { var local = 5; }') as out:
            from slimit.minifier import main
            main(['-m'])

        self.assertEqual('function foo(){var a=5;}', out.getvalue())
        if old_module is not None:
            sys.modules['slimit.minifier'] = old_module
Ejemplo n.º 8
0
    def test_main_stdin_stdout(self):
        # slimit.minifier should be deleted from sys.modules in order
        # to have a proper reference to sys.stdin and sys.stdou when
        # 'main' definition is evaluated during module import
        old_module = None
        try:
            old_module = sys.modules.pop('slimit.minifier')
        except KeyError:
            pass

        with redirected_input_output(
                input='function foo() { var local = 5; }') as out:
            from slimit.minifier import main
            main(['-m'])

        self.assertEqual('function foo(){var a=5;}', out.getvalue())
        if old_module is not None:
            sys.modules['slimit.minifier'] = old_module
Ejemplo n.º 9
0
 def test_main_dash_m_with_mock_stdin(self):
     from slimit.minifier import main
     out = io.StringIO()
     inp = io.StringIO('function foo() { var local = 5; }')
     main(['-m'], inp=inp, out=out)
     self.assertEqual('function foo(){var a=5;}', out.getvalue())
Ejemplo n.º 10
0
 def test_main_dash_dash_mangle_with_input_file(self):
     from slimit.minifier import main
     out = io.StringIO()
     main(['--mangle', '--mangle-toplevel', self.path], out=out)
     self.assertEqual('var a=5;', out.getvalue())
Ejemplo n.º 11
0
 def test_main_dash_m_with_mock_stdin(self):
     from slimit.minifier import main
     out = StringIO.StringIO()
     inp = StringIO.StringIO('function foo() { var local = 5; }')
     main(['-m'], inp=inp, out=out)
     self.assertEqual('function foo(){var a=5;}', out.getvalue())
Ejemplo n.º 12
0
 def test_main_dash_dash_mangle_with_input_file(self):
     from slimit.minifier import main
     out = StringIO.StringIO()
     main(['--mangle', '--mangle-toplevel', self.path], out=out)
     self.assertEqual('var a=5;', out.getvalue())
Ejemplo n.º 13
0
    def test_main_dash_dash_mangle_with_input_file(self):
        from slimit.minifier import main

        out = StringIO.StringIO()
        main(["--mangle", self.path], out=out)
        self.assertEqual("var a=5;", out.getvalue())
Ejemplo n.º 14
0
 def test_main_dash_m_with_input_file(self):
     from slimit.minifier import main
     out = StringIO.StringIO()
     main(['-m', '-t', self.path], out=out)
     self.assertEqual('var a=5;', out.getvalue())