@@ -410,97 +410,6 @@ def test_extract_strip_comment_tags(self):
410
410
u'a prefix too' ], messages [1 ][2 ])
411
411
412
412
413
- class ExtractJavaScriptTestCase (unittest .TestCase ):
414
-
415
- def test_simple_extract (self ):
416
- buf = BytesIO (b"""\
417
- msg1 = _('simple')
418
- msg2 = gettext('simple')
419
- msg3 = ngettext('s', 'p', 42)
420
- """ )
421
- messages = \
422
- list (extract .extract ('javascript' , buf , extract .DEFAULT_KEYWORDS ,
423
- [], {}))
424
-
425
- self .assertEqual ([(1 , 'simple' , [], None ),
426
- (2 , 'simple' , [], None ),
427
- (3 , ('s' , 'p' ), [], None )], messages )
428
-
429
- def test_various_calls (self ):
430
- buf = BytesIO (b"""\
431
- msg1 = _(i18n_arg.replace(/"/, '"'))
432
- msg2 = ungettext(i18n_arg.replace(/"/, '"'), multi_arg.replace(/"/, '"'), 2)
433
- msg3 = ungettext("Babel", multi_arg.replace(/"/, '"'), 2)
434
- msg4 = ungettext(i18n_arg.replace(/"/, '"'), "Babels", 2)
435
- msg5 = ungettext('bunny', 'bunnies', parseInt(Math.random() * 2 + 1))
436
- msg6 = ungettext(arg0, 'bunnies', rparseInt(Math.random() * 2 + 1))
437
- msg7 = _(hello.there)
438
- msg8 = gettext('Rabbit')
439
- msg9 = dgettext('wiki', model.addPage())
440
- msg10 = dngettext(domain, 'Page', 'Pages', 3)
441
- """ )
442
- messages = \
443
- list (extract .extract ('javascript' , buf , extract .DEFAULT_KEYWORDS , [],
444
- {}))
445
- self .assertEqual ([(5 , (u'bunny' , u'bunnies' ), [], None ),
446
- (8 , u'Rabbit' , [], None ),
447
- (10 , (u'Page' , u'Pages' ), [], None )], messages )
448
-
449
- def test_message_with_line_comment (self ):
450
- buf = BytesIO (u"""\
451
- // NOTE: hello
452
- msg = _('Bonjour à tous')
453
- """ .encode ('utf-8' ))
454
- messages = list (extract .extract_javascript (buf , ('_' ,), ['NOTE:' ], {}))
455
- self .assertEqual (u'Bonjour à tous' , messages [0 ][2 ])
456
- self .assertEqual ([u'NOTE: hello' ], messages [0 ][3 ])
457
-
458
- def test_message_with_multiline_comment (self ):
459
- buf = BytesIO (u"""\
460
- /* NOTE: hello
461
- and bonjour
462
- and servus */
463
- msg = _('Bonjour à tous')
464
- """ .encode ('utf-8' ))
465
- messages = list (extract .extract_javascript (buf , ('_' ,), ['NOTE:' ], {}))
466
- self .assertEqual (u'Bonjour à tous' , messages [0 ][2 ])
467
- self .assertEqual ([u'NOTE: hello' , 'and bonjour' , ' and servus' ], messages [0 ][3 ])
468
-
469
- def test_ignore_function_definitions (self ):
470
- buf = BytesIO (b"""\
471
- function gettext(value) {
472
- return translations[language][value] || value;
473
- }""" )
474
-
475
- messages = list (extract .extract_javascript (buf , ('gettext' ,), [], {}))
476
- self .assertEqual (messages , [])
477
-
478
- def test_misplaced_comments (self ):
479
- buf = BytesIO (b"""\
480
- /* NOTE: this won't show up */
481
- foo()
482
-
483
- /* NOTE: this will */
484
- msg = _('Something')
485
-
486
- // NOTE: this will show up
487
- // too.
488
- msg = _('Something else')
489
-
490
- // NOTE: but this won't
491
- bar()
492
-
493
- _('no comment here')
494
- """ )
495
- messages = list (extract .extract_javascript (buf , ('_' ,), ['NOTE:' ], {}))
496
- self .assertEqual (u'Something' , messages [0 ][2 ])
497
- self .assertEqual ([u'NOTE: this will' ], messages [0 ][3 ])
498
- self .assertEqual (u'Something else' , messages [1 ][2 ])
499
- self .assertEqual ([u'NOTE: this will show up' , 'too.' ], messages [1 ][3 ])
500
- self .assertEqual (u'no comment here' , messages [2 ][2 ])
501
- self .assertEqual ([], messages [2 ][3 ])
502
-
503
-
504
413
class ExtractTestCase (unittest .TestCase ):
505
414
506
415
def test_invalid_filter (self ):
0 commit comments