def test_get_pallets_in_file_same_pallet_twice(self): #: we should be able to import a pallet more than once from the same file #: use case is when you run a specific pallet that is located in the warehouse pallets, _ = engine._get_pallets_in_file(join(test_data_folder, 'duplicate_import.py')) pallets2, _ = engine._get_pallets_in_file(join(test_data_folder, 'duplicate_import.py')) try: #: does not raise for info in pallets: info[1]() for info in pallets2: info[1]() except Exception as e: self.fail(e)
def test_list_pallets_order(self): pallets, _ = engine._get_pallets_in_file( join(test_data_folder, 'pallet_order.py')) self.assertEqual(pallets[0][1].__name__, 'PalletA') self.assertEqual(pallets[1][1].__name__, 'PalletB') self.assertEqual(pallets[2][1].__name__, 'PalletC')
def test_pallet_with_import_error(self): _, import_error = engine._get_pallets_in_file( join(test_folder, 'PalletWithSyntaxErrors.py')) self.assertRegexpMatches(import_error, 'expected an indented block')
def test_get_specific_pallet_in_file(self): pallets, _ = engine._get_pallets_in_file( join(test_data_folder, 'pallet_order.py:PalletB')) self.assertEqual(len(pallets), 1) self.assertEqual(pallets[0][1].__name__, 'PalletB')