Ticket #7158: patch.diff
File patch.diff, 7.8 KB (added by , 17 years ago) |
---|
-
django/test/simple.py
73 73 pass 74 74 return suite 75 75 76 def _get_all_tests_from_suite(suite): 77 """Explore suite recursively to get _all_ tests in it 78 """ 79 if isinstance(suite,unittest.TestCase): 80 return [suite] 81 else: 82 all_tests = [] 83 [all_tests.extend(_get_all_tests_from_suite(sub_suite)) for sub_suite in getattr(suite,'_tests',[])] 84 return all_tests 85 76 86 def build_test(label): 77 87 """Construct a test case a test with the specified label. Label should 78 88 be of the form model.TestClass or model.TestClass.test_method. Returns … … 92 102 if test_module: 93 103 TestClass = getattr(test_module, parts[1], None) 94 104 105 # Couldn't find the test class; look in test suite 106 if TestClass is None: 107 suite = build_suite(app_module) 108 all_tests = _get_all_tests_from_suite(suite) 109 for test_in_suite in all_tests: 110 if test_in_suite.__class__.__name__ == parts[1]: 111 TestClass = test_in_suite.__class__ 112 break 113 95 114 if len(parts) == 2: # label is app.TestClass 96 115 try: 97 116 return unittest.TestLoader().loadTestsFromTestCase(TestClass) -
django/core/management/commands/syncdb.py
34 34 try: 35 35 __import__(app_name + '.management', {}, {}, ['']) 36 36 except ImportError, exc: 37 if not exc.args[0].startswith('No module named management'): 38 raise 37 # RBA : strange uno error : we need to be more permissive with errors 38 #if not exc.args[0].startswith('No module named management'): 39 # raise 40 pass 39 41 40 42 cursor = connection.cursor() 41 43 -
django/core/management/__init__.py
249 249 settings_name = os.path.splitext(settings_filename)[0] 250 250 sys.path.append(os.path.join(project_directory, os.pardir)) 251 251 project_module = __import__(project_name, {}, {}, ['']) 252 sys.path.pop()252 #sys.path.pop() 253 253 254 254 # Set DJANGO_SETTINGS_MODULE appropriately. 255 255 os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name) -
django/templatetags/i18n.py
1 1 import re 2 2 3 3 from django.template import Node, Variable, VariableNode 4 from django.template import TemplateSyntaxError, TokenParser, Library 5 from django.template import TOKEN_TEXT, TOKEN_VAR 4 from django.template import TemplateSyntaxError, TokenParser, Library, Token 5 from django.template import TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK 6 6 from django.utils import translation 7 7 from django.utils.encoding import force_unicode 8 8 … … 235 235 token = parser.next_token() 236 236 if token.token_type in (TOKEN_VAR, TOKEN_TEXT): 237 237 singular.append(token) 238 elif token.token_type == TOKEN_BLOCK and token.contents.strip().startswith('as '): 239 cont = token.split_contents() 240 if len(cont) != 2: 241 raise TemplateSyntaxError, "Error in 'as' block inside blocktrans" 242 as_tag,name = token.split_contents() 243 t_block = parser.parse(('endas',)) 244 singular.append(token) 245 parser.delete_first_token() 246 extra_context[name] = t_block 247 singular.append(Token(TOKEN_VAR,name)) 238 248 else: 239 249 break 240 250 if countervar and counter: 241 251 if token.contents.strip() != 'plural': 242 raise TemplateSyntaxError, "'blocktrans' doesn't allow other block tags inside it"252 raise TemplateSyntaxError, "'blocktrans' can only include 'as' block tags" 243 253 while parser.tokens: 244 254 token = parser.next_token() 245 255 if token.token_type in (TOKEN_VAR, TOKEN_TEXT): 246 256 plural.append(token) 257 elif token.token_type == TOKEN_BLOCK and token.contents.strip().startswith('as '): 258 cont = token.split_contents() 259 if len(cont) != 2: 260 raise TemplateSyntaxError, "Error in 'as' block inside blocktrans" 261 as_tag,name = cont 262 t_block = parser.parse(('endas',)) 263 plural.append(token) 264 parser.delete_first_token() 265 extra_context[name] = t_block 266 plural.append(Token(TOKEN_VAR,name)) 247 267 else: 248 268 break 249 269 if token.contents.strip() != 'endblocktrans': 250 raise TemplateSyntaxError, "'blocktrans' doesn't allow otherblock tags (seen %r) inside it" % token.contents270 raise TemplateSyntaxError, "'blocktrans' can only include 'as' block tags (seen %r) inside it" % token.contents 251 271 252 272 return BlockTranslateNode(extra_context, singular, plural, countervar, 253 273 counter) -
django/utils/translation/trans_real.py
452 452 inplural = False 453 453 singular = [] 454 454 plural = [] 455 inas = False 455 456 for t in Lexer(src, None).tokenize(): 456 457 if intrans: 457 458 if t.token_type == TOKEN_BLOCK: 458 459 endbmatch = endblock_re.match(t.contents) 459 pluralmatch = plural_re.match(t.contents) 460 pluralmatch = plural_re.match(t.contents) 460 461 if endbmatch: 461 462 if inplural: 462 463 out.write(' ngettext(%r,%r,count) ' % (''.join(singular), ''.join(plural))) … … 475 476 elif pluralmatch: 476 477 inplural = True 477 478 else: 478 raise SyntaxError("Translation blocks must not include other block tags: %s" % t.contents) 479 if t.contents.startswith('as '): 480 cont = t.split_contents() 481 if len(cont) != 2: 482 raise TemplateSyntaxError, "Error in 'as' block inside blocktrans" 483 as_tag,name = cont 484 inas = True 485 if inplural: 486 plural.append('%%(%s)s' % name) 487 else: 488 singular.append('%%(%s)s' % name) 489 elif t.contents == "endas": 490 inas = False 491 else: 492 raise SyntaxError("Translation blocks can only include 'as' block tags: %s" % t.contents) 479 493 elif t.token_type == TOKEN_VAR: 480 494 if inplural: 481 495 plural.append('%%(%s)s' % t.contents) 482 496 else: 483 497 singular.append('%%(%s)s' % t.contents) 484 498 elif t.token_type == TOKEN_TEXT: 485 if inplural: 486 plural.append(t.contents) 487 else: 488 singular.append(t.contents) 499 if not inas: 500 if inplural: 501 plural.append(t.contents) 502 else: 503 singular.append(t.contents) 489 504 else: 490 505 if t.token_type == TOKEN_BLOCK: 491 506 imatch = inline_re.match(t.contents)