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_no_newline_in_extended_default_imports(self): imports = determine_imports(extra_imports='import another.class', with_default_imports=True) 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 noseOfYeti .tokeniser .support import *' )
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_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 ''')
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 ''' )
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()
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 , with_describe_attrs = not self.config.no_describe_attrs ) TokeniserCodec(tok).register()
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 , with_describe_attrs = not config.get('noy_no_describe_attrs')[0] ) TokeniserCodec(tok).register()
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()
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 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 , with_describe_attrs = not options.no_describe_attrs ) TokeniserCodec(tok).register()
def test_determine_imports_imports_nothing_by_default(self): imports = determine_imports() tok = Tokeniser(import_tokens=imports) (tok, '') |should| result_in('')
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_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')
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_determine_imports_imports_nothing_by_default(self): imports = determine_imports() tok = Tokeniser(import_tokens=imports) (tok, '') | should | result_in('')
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')
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_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 ')