~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lazy_import.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-11 22:48:57 UTC
  • mto: This revision was merged to the branch mainline in revision 2004.
  • Revision ID: john@arbash-meinel.com-20060911224857-d7008be21aeee33e
Switch from individual functions to a class

Show diffs side-by-side

added added

removed removed

Lines of Context:
575
575
    """Directly test the conversion from import strings to maps"""
576
576
 
577
577
    def check_result(self, expected, import_strings):
578
 
        imports = {}
 
578
        proc = lazy_import.ImportProcessor()
579
579
        for import_str in import_strings:
580
 
            lazy_import._convert_import_str_to_map(import_str, imports)
581
 
        self.assertEqual(expected, imports,
 
580
            proc._convert_import_str(import_str)
 
581
        self.assertEqual(expected, proc.imports,
582
582
                         'Import of %r was not converted correctly'
583
 
                         ' %s != %s' % (import_strings, expected, imports))
 
583
                         ' %s != %s' % (import_strings, expected,
 
584
                                        proc.imports))
584
585
 
585
586
    def test_import_one(self):
586
587
        self.check_result({'one':(['one'], None, {}),
637
638
    """Directly test the conversion of 'from foo import bar' syntax"""
638
639
 
639
640
    def check_result(self, expected, from_strings):
640
 
        imports = {}
 
641
        proc = lazy_import.ImportProcessor()
641
642
        for from_str in from_strings:
642
 
            lazy_import._convert_from_str_to_map(from_str, imports)
643
 
        self.assertEqual(expected, imports,
 
643
            proc._convert_from_str(from_str)
 
644
        self.assertEqual(expected, proc.imports,
644
645
                         'Import of %r was not converted correctly'
645
 
                         ' %s != %s' % (from_strings, expected, imports))
 
646
                         ' %s != %s' % (from_strings, expected, proc.imports))
646
647
 
647
648
    def test_from_one_import_two(self):
648
649
        self.check_result({'two':(['one'], 'two', {})},
671
672
    """Test that we can canonicalize import texts"""
672
673
 
673
674
    def check(self, expected, text):
674
 
        parsed = lazy_import._canonicalize_import_strings(text)
 
675
        proc = lazy_import.ImportProcessor()
 
676
        parsed = proc._canonicalize_import_strings(text)
675
677
        self.assertEqual(expected, parsed,
676
678
                         'Incorrect parsing of text:\n%s\n%s\n!=\n%s'
677
679
                         % (text, expected, parsed))