Ejemplo n.º 1
0
 def test_extra_arguments(self, capsys):
     '''Test that extra arguments to Computation subclasses are handled
     correctly.
     '''
     env = Environment(ConfigObj())
     my_param = 3
     env.register_class(self.TestArguments, None, True,
                        my_param, kwarg=10)
     env.run()
     out, _ = capsys.readouterr()
     assert out == "3\n10\n"
Ejemplo n.º 2
0
 def test_extra_arguments(self, capsys):
     '''Test that extra arguments to Computation subclasses are handled
     correctly.
     '''
     env = Environment(ConfigObj())
     my_param = 3
     env.register_class(self.TestArguments, None, True, my_param, kwarg=10)
     env.run()
     out, _ = capsys.readouterr()
     assert out == "3\n10\n"
Ejemplo n.º 3
0
    def test_running(self, capsys):
        '''Test runs with several classes.'''
        config = ConfigObj({
            'NumPrinter' : {
                'number' : 1,
            },
        })

        # No object-specific configurations
        env = Environment(config)
        for i in range(3):
            env.register_class(self.NumPrinter)
        env.run()
        out, _ = capsys.readouterr()
        assert out == "1\n1\n1\n"

        # Each object except the first has a specific configuration
        env = Environment(config)
        env.register_plotter(self.NumPrinter)
        for i in range(3):
            env.register_class(self.NumPrinter, config={
                'NumPrinter': {
                    'number' : i + 2,
                },
            })
        env.run()
        out, _ = capsys.readouterr()
        assert out == "1\n2\n3\n4\n"
Ejemplo n.º 4
0
    def test_running(self, capsys):
        '''Test runs with several classes.'''
        config = ConfigObj({
            'NumPrinter': {
                'number': 1,
            },
        })

        # No object-specific configurations
        env = Environment(config)
        for i in range(3):
            env.register_class(self.NumPrinter)
        env.run()
        out, _ = capsys.readouterr()
        assert out == "1\n1\n1\n"

        # Each object except the first has a specific configuration
        env = Environment(config)
        env.register_plotter(self.NumPrinter)
        for i in range(3):
            env.register_class(self.NumPrinter,
                               config={
                                   'NumPrinter': {
                                       'number': i + 2,
                                   },
                               })
        env.run()
        out, _ = capsys.readouterr()
        assert out == "1\n2\n3\n4\n"
Ejemplo n.º 5
0
 def test_config(self):
     '''Test config correctness.'''
     config = ConfigObj({'test': 10})
     env = Environment(config)
     assert env.config == config