def test_no_newline_in_extended_default_imports(self):
     imports = determine_imports(extra_imports='import another.class')
     tok = Tokeniser(import_tokens=imports)
     tok.import_tokens | should_not | contain([NEWLINE, '\n'])
     (tok, '') | should | result_in(
         'import another .class ;import nose ;from nose .tools import *;from should_dsl import *;from noseOfYeti .tokeniser .support import *'
     )
 def test_determine_imports_imports_nose_and_nose_helpers_and_should_dsl_by_default(
         self):
     imports = determine_imports()
     tok = Tokeniser(import_tokens=imports)
     (tok, '') | should | result_in(
         'import nose ;from nose .tools import *;from should_dsl import *;from noseOfYeti .tokeniser .support import *'
     )
 def test_gives_describes_noy_specific_attributes(self):
     imports = determine_imports(with_default_imports=False)
     tok = Tokeniser(import_tokens=imports)
     (tok, 'describe "Something testable"') | should | result_in('''
     class TestSomethingTestable (object ):pass 
     
     TestSomethingTestable .is_noy_spec =True 
     ''')
Ejemplo n.º 4
0
    def open(self):
        imports = determine_imports(
            extra_imports=';'.join([d for d in self.config.extra_import if d]),
            without_should_dsl=self.config.without_should_dsl,
            with_default_imports=not self.config.no_default_imports)

        tok = Tokeniser(default_kls=self.config.default_kls,
                        import_tokens=imports,
                        wrapped_setup=self.config.wrapped_setup,
                        with_describe_attrs=not self.config.no_describe_attrs)

        TokeniserCodec(tok).register()
Ejemplo n.º 5
0
def enable(app):
    config = app.builder.config.values
    imports = determine_imports(
          extra_imports = ';'.join([d for d in config.get('noy_extra_import')[0] if d])
        , without_should_dsl = config.get('noy_without_should_dsl')[0]
        , with_default_imports = not config.get('noy_no_default_imports')[0]
        )
    
    tok = Tokeniser(
          default_kls = config.get('noy_default_kls')[0]
        , import_tokens = imports
        , wrapped_setup = options.wrapped_setup
        , with_describe_attrs = not config.get('noy_no_describe_attrs')[0]
        )
    
    TokeniserCodec(tok).register()
Ejemplo n.º 6
0
    def configure(self, options, conf):
        super(Plugin, self).configure(options, conf)
        self.ignore_kls = options.ignore_kls
        if options.enabled:
            self.enabled = True
            self.done = {}
            imports = determine_imports(
                extra_imports=';'.join([d for d in options.extra_import if d]),
                without_should_dsl=options.without_should_dsl,
                with_default_imports=not options.no_default_imports)

            tok = Tokeniser(default_kls=options.default_kls,
                            import_tokens=imports,
                            wrapped_setup=options.wrapped_setup,
                            with_describe_attrs=not options.no_describe_attrs)

            TokeniserCodec(tok).register()
 def setUp(self):
     self.toka = Tokeniser(with_describe_attrs=False)
     self.tokb = Tokeniser(with_describe_attrs=False, default_kls = 'other')
Ejemplo n.º 8
0
    def setUp(self):
        self.toka = Tokeniser(with_describe_attrs=False)
        self.tokb = Tokeniser(with_describe_attrs=False, default_kls='other')

        ###   SMALL EXAMPLE (WITHOUT PASS)

        self.small_example = [
            '''
        describe "This":
            describe "That":

                describe "Meh":pass
            context "Blah":pass
        describe "Another":pass ''', '''
        class TestThis (%(o)s ):pass 
        class TestThis_That (TestThis ):pass 
        class TestThis_That_Meh (TestThis_That ):pass 
        class TestThis_Blah (TestThis ):pass 
        class TestAnother (%(o)s ):pass 
        '''
        ]

        ###   SMALL EXAMPLE (WITH PATH FOR BW COMPAT)

        self.small_example_with_pass = [
            '''
        context "This":pass
            describe "That":pass
                describe "Meh":pass
            describe "Blah":pass
        describe "Another":pass ''', '''
        class TestThis (%(o)s ):pass 
        class TestThis_That (TestThis ):pass 
        class TestThis_That_Meh (TestThis_That ):pass 
        class TestThis_Blah (TestThis ):pass 
        class TestAnother (%(o)s ):pass 
        '''
        ]

        ###   BIG EXAMPLE

        self.big_example = [
            '''
        describe "This":
            it 'should':
                if x:
                    pass
                else:
                    x += 9
            describe "That":
                describe "Meh":
                    it 'should':
                        if y:
                            pass
                        else:
                            pass
            describe "Blah":pass
        describe "Another":
            it 'should':
                if z:
                    if u:
                        print "hello \
                            there"
                    else:
                        print "no"
                else:
                    pass
        ''', '''
        class TestThis (%(o)s ):
            def test_should (self ):
                if x :
                    pass 
                else :
                    x +=9 
        class TestThis_That (TestThis ):pass 
        class TestThis_That_Meh (TestThis_That ):
            def test_should (self ):
                if y :
                    pass 
                else :
                    pass 
        class TestThis_Blah (TestThis ):pass 
        class TestAnother (%(o)s ):
            def test_should (self ):
                if z :
                    if u :
                        print "hello \
                            there"
                    else :
                        print "no"
                else :
                    pass 
        '''
        ]
Ejemplo n.º 9
0
    def setUp(self):
        self.toka = Tokeniser()
        self.tokb = Tokeniser(default_kls='other')

        ###   SMALL EXAMPLE

        self.small_example = [
            '''
        describe "This":
            before_each:
                self.x = 5
            describe "That":
                before_each:
                    self.y = 6
                describe "Meh":
                    after_each:
                        self.y = None
            describe "Blah":pass
        describe "Another":
            before_each:
                self.z = 8 ''', '''
        class TestThis (%(o)s ):
            def setUp (self ):
                noy_sup_setUp (super (TestThis ,self ));self .x =5
        class TestThis_That (TestThis ):
            def setUp (self ):
                noy_sup_setUp (super (TestThis_That ,self ));self .y =6
        class TestThis_That_Meh (TestThis_That ):
            def tearDown (self ):
                noy_sup_tearDown (super (TestThis_That_Meh ,self ));self .y =None
        class TestThis_Blah (TestThis ):pass
        class TestAnother (%(o)s ):
            def setUp (self ):
                noy_sup_setUp (super (TestAnother ,self ));self .z =8

        TestThis .is_noy_spec =True
        TestThis_That .is_noy_spec =True
        TestThis_That_Meh .is_noy_spec =True
        TestThis_Blah .is_noy_spec =True
        TestAnother .is_noy_spec =True
        '''
        ]

        ###   BIG EXAMPLE

        self.big_example = [
            '''
        describe "This":
            before_each:
                self.x = 5
            it 'should':
                if x:
                    pass
                else:
                    x += 9
            describe "That":
                before_each:
                    self.y = 6
                describe "Meh":
                    after_each:
                        self.y = None
                    it "should set __testname__ for non alpha names ' $^":
                        pass
                    it 'should':
                        if y:
                            pass
                        else:
                            pass
                    it 'should have args', arg1, arg2:
                        blah |should| be_good()
            describe "Blah":pass
        ignore "root level $pecial-method*+"
        describe "Another":
            before_each:
                self.z = 8
            it 'should':
                if z:
                    if u:
                        print "hello \
                            there"
                    else:
                        print "no"
                else:
                    pass
        ''', '''
        class TestThis (%(o)s ):
            def setUp (self ):
                noy_sup_setUp (super (TestThis ,self ));self .x =5
            def test_should (self ):
                if x :
                    pass
                else :
                    x +=9
        class TestThis_That (TestThis ):
            def setUp (self ):
                noy_sup_setUp (super (TestThis_That ,self ));self .y =6
        class TestThis_That_Meh (TestThis_That ):
            def tearDown (self ):
                noy_sup_tearDown (super (TestThis_That_Meh ,self ));self .y =None
            def test_should_set_testname_for_non_alpha_names (self ):
                pass
            def test_should (self ):
                if y :
                    pass
                else :
                    pass
            def test_should_have_args (self ,arg1 ,arg2 ):
                blah |should |be_good ()
        class TestThis_Blah (TestThis ):pass
        def ignore__root_level_pecial_method ():raise nose.SkipTest
        class TestAnother (%(o)s ):
            def setUp (self ):
                noy_sup_setUp (super (TestAnother ,self ));self .z =8
            def test_should (self ):
                if z :
                    if u :
                        print "hello \
                            there"
                    else :
                        print "no"
                else :
                    pass

        TestThis .is_noy_spec =True
        TestThis_That .is_noy_spec =True
        TestThis_That_Meh .is_noy_spec =True
        TestThis_Blah .is_noy_spec =True
        TestAnother .is_noy_spec =True
        ignore__root_level_pecial_method .__testname__ ="root level $pecial-method*+"
        TestThis_That_Meh .test_should_set_testname_for_non_alpha_names .{func_accessor}__testname__ ="should set __testname__ for non alpha names ' $^"
        '''.format(func_accessor=func_accessor)
        ]
 def test_is_possible_to_specify_extra_imports_without_default_imports(
         self):
     imports = determine_imports(with_default_imports=False,
                                 extra_imports="import thing")
     tok = Tokeniser(import_tokens=imports)
     (tok, '') | should | result_in('import thing ')
 def test_tokeniser_has_no_default_imports_by_default(self):
     tok = Tokeniser()
     tok.import_tokens | should | equal_to(None)
 def test_no_newline_in_default_imports(self):
     tok = Tokeniser(import_tokens=determine_imports())
     tok.import_tokens | should_not | contain([NEWLINE, '\n'])
 def test_is_possible_to_turn_off_attributes(self):
     imports = determine_imports(with_default_imports=False)
     tok = Tokeniser(import_tokens=imports, with_describe_attrs=False)
     (tok, 'describe "Something testable"'
      ) | should | result_in('class TestSomethingTestable (object ):pass')
Ejemplo n.º 14
0
 def test_determine_imports_imports_nothing_by_default(self):
     imports = determine_imports()
     tok = Tokeniser(import_tokens=imports)
     (tok, '') | should | result_in('')