Пример #1
0
    def test_dictionary_factor(self):
        input_attrs = deepcopy(self.test_attrs)
        dict_subset_attrs = deepcopy(self.test_attrs)
        overlapping_dict_attrs = deepcopy(self.test_attrs)

        del dict_subset_attrs["DEFINES"]["DEBUG"]
        overlapping_dict_attrs["DEFINES"]["MOZ_DEBUG"] = True

        common_attrs = find_common_attrs(
            [input_attrs, dict_subset_attrs, overlapping_dict_attrs]
        )
        for attr in ("LIBRARY_NAME", "LOCAL_INCLUDES"):
            self.assertEqual(common_attrs[attr], self.test_attrs[attr])
            self.assertFalse(input_attrs.get(attr))
            self.assertFalse(dict_subset_attrs.get(attr))
            self.assertFalse(overlapping_dict_attrs.get(attr))
        self.assertEqual(common_attrs["DEFINES"], {"UNICODE": True})
        self.assertEqual(dict_subset_attrs["DEFINES"], {})
        self.assertEqual(
            overlapping_dict_attrs["DEFINES"],
            {
                "DEBUG": True,
                "MOZ_DEBUG": True,
            },
        )
Пример #2
0
 def test_list_factor(self):
     list_attrs = deepcopy(self.test_attrs)
     input_attrs = deepcopy(self.test_attrs)
     list_attrs['LOCAL_INCLUDES'] += ['/local/include']
     list_attrs['LOCAL_INCLDUES'] = list(reversed(list_attrs['LOCAL_INCLUDES']))
     common_attrs = find_common_attrs([input_attrs, list_attrs])
     self.assertEqual(list_attrs['LOCAL_INCLUDES'], ['/local/include'])
     self.assertEqual(self.test_attrs, common_attrs)
     self.assertFalse(any(v for v in input_attrs.values()))
Пример #3
0
 def test_list_factor(self):
     list_attrs = deepcopy(self.test_attrs)
     input_attrs = deepcopy(self.test_attrs)
     list_attrs["LOCAL_INCLUDES"] += ["/local/include"]
     list_attrs["LOCAL_INCLDUES"] = list(reversed(list_attrs["LOCAL_INCLUDES"]))
     common_attrs = find_common_attrs([input_attrs, list_attrs])
     self.assertEqual(list_attrs["LOCAL_INCLUDES"], ["/local/include"])
     self.assertEqual(self.test_attrs, common_attrs)
     self.assertFalse(any(v for v in input_attrs.values()))
Пример #4
0
    def test_common_attrs(self):
        input_attrs = deepcopy(self.test_attrs)
        dict_subset_attrs = deepcopy(self.test_attrs)

        del dict_subset_attrs['DEFINES']
        common_attrs = find_common_attrs([input_attrs, dict_subset_attrs])
        self.assertNotIn('DEFINES', common_attrs)
        expected_common = deepcopy(self.test_attrs)
        del expected_common['DEFINES']
        self.assertEqual(expected_common, common_attrs)
        for attr_set in (input_attrs, dict_subset_attrs):
            self.assertNotIn('LIBRARY_NAME', attr_set)
            self.assertEqual(attr_set['LOCAL_INCLUDES'], [])
Пример #5
0
    def test_common_attrs(self):
        input_attrs = deepcopy(self.test_attrs)
        dict_subset_attrs = deepcopy(self.test_attrs)

        del dict_subset_attrs["DEFINES"]
        common_attrs = find_common_attrs([input_attrs, dict_subset_attrs])
        self.assertNotIn("DEFINES", common_attrs)
        expected_common = deepcopy(self.test_attrs)
        del expected_common["DEFINES"]
        self.assertEqual(expected_common, common_attrs)
        for attr_set in (input_attrs, dict_subset_attrs):
            self.assertNotIn("LIBRARY_NAME", attr_set)
            self.assertEqual(attr_set["LOCAL_INCLUDES"], [])
Пример #6
0
 def test_value_factor(self):
     input_attrs = deepcopy(self.test_attrs)
     value_attrs = deepcopy(self.test_attrs)
     value_attrs['LOCAL_INCLUDES'] = ['/local/include']
     value_attrs['DEFINES']['DEBUG'] = False
     value_attrs['DEFINES']['UNICODE'] = False
     common_attrs = find_common_attrs([value_attrs, input_attrs])
     self.assertEqual(common_attrs['LIBRARY_NAME'], 'Foo')
     self.assertNotIn('LIBRARY_NAME', value_attrs)
     self.assertNotIn('LIBRARY_NAME', input_attrs)
     del common_attrs['LIBRARY_NAME']
     self.assertFalse(any(v for v in common_attrs.values()))
     self.assertEqual(input_attrs['LOCAL_INCLUDES'], self.test_attrs['LOCAL_INCLUDES'])
     self.assertEqual(input_attrs['DEFINES'], self.test_attrs['DEFINES'])
     self.assertEqual(value_attrs['LOCAL_INCLUDES'],  ['/local/include'])
     self.assertEqual(value_attrs['DEFINES'],  {'DEBUG': False, 'UNICODE': False})
Пример #7
0
 def test_value_factor(self):
     input_attrs = deepcopy(self.test_attrs)
     value_attrs = deepcopy(self.test_attrs)
     value_attrs["LOCAL_INCLUDES"] = ["/local/include"]
     value_attrs["DEFINES"]["DEBUG"] = False
     value_attrs["DEFINES"]["UNICODE"] = False
     common_attrs = find_common_attrs([value_attrs, input_attrs])
     self.assertEqual(common_attrs["LIBRARY_NAME"], "Foo")
     self.assertNotIn("LIBRARY_NAME", value_attrs)
     self.assertNotIn("LIBRARY_NAME", input_attrs)
     del common_attrs["LIBRARY_NAME"]
     self.assertFalse(any(v for v in common_attrs.values()))
     self.assertEqual(
         input_attrs["LOCAL_INCLUDES"], self.test_attrs["LOCAL_INCLUDES"]
     )
     self.assertEqual(input_attrs["DEFINES"], self.test_attrs["DEFINES"])
     self.assertEqual(value_attrs["LOCAL_INCLUDES"], ["/local/include"])
     self.assertEqual(value_attrs["DEFINES"], {"DEBUG": False, "UNICODE": False})
Пример #8
0
    def test_dictionary_factor(self):
        input_attrs = deepcopy(self.test_attrs)
        dict_subset_attrs = deepcopy(self.test_attrs)
        overlapping_dict_attrs = deepcopy(self.test_attrs)

        del dict_subset_attrs['DEFINES']['DEBUG']
        overlapping_dict_attrs['DEFINES']['MOZ_DEBUG'] = True

        common_attrs = find_common_attrs([input_attrs, dict_subset_attrs, overlapping_dict_attrs])
        for attr in ('LIBRARY_NAME', 'LOCAL_INCLUDES'):
            self.assertEqual(common_attrs[attr], self.test_attrs[attr])
            self.assertFalse(input_attrs.get(attr))
            self.assertFalse(dict_subset_attrs.get(attr))
            self.assertFalse(overlapping_dict_attrs.get(attr))
        self.assertEqual(common_attrs['DEFINES'], {'UNICODE': True})
        self.assertEqual(dict_subset_attrs['DEFINES'], {})
        self.assertEqual(overlapping_dict_attrs['DEFINES'], {
            'DEBUG': True,
            'MOZ_DEBUG': True,
        })
Пример #9
0
 def test_value_factor(self):
     input_attrs = deepcopy(self.test_attrs)
     value_attrs = deepcopy(self.test_attrs)
     value_attrs['LOCAL_INCLUDES'] = ['/local/include']
     value_attrs['DEFINES']['DEBUG'] = False
     value_attrs['DEFINES']['UNICODE'] = False
     common_attrs = find_common_attrs([value_attrs, input_attrs])
     self.assertEqual(common_attrs['LIBRARY_NAME'], 'Foo')
     self.assertNotIn('LIBRARY_NAME', value_attrs)
     self.assertNotIn('LIBRARY_NAME', input_attrs)
     del common_attrs['LIBRARY_NAME']
     self.assertFalse(any(v for v in common_attrs.values()))
     self.assertEqual(input_attrs['LOCAL_INCLUDES'],
                      self.test_attrs['LOCAL_INCLUDES'])
     self.assertEqual(input_attrs['DEFINES'], self.test_attrs['DEFINES'])
     self.assertEqual(value_attrs['LOCAL_INCLUDES'], ['/local/include'])
     self.assertEqual(value_attrs['DEFINES'], {
         'DEBUG': False,
         'UNICODE': False
     })
Пример #10
0
    def test_dictionary_factor(self):
        input_attrs = deepcopy(self.test_attrs)
        dict_subset_attrs = deepcopy(self.test_attrs)
        overlapping_dict_attrs = deepcopy(self.test_attrs)

        del dict_subset_attrs['DEFINES']['DEBUG']
        overlapping_dict_attrs['DEFINES']['MOZ_DEBUG'] = True

        common_attrs = find_common_attrs(
            [input_attrs, dict_subset_attrs, overlapping_dict_attrs])
        for attr in ('LIBRARY_NAME', 'LOCAL_INCLUDES'):
            self.assertEqual(common_attrs[attr], self.test_attrs[attr])
            self.assertFalse(input_attrs.get(attr))
            self.assertFalse(dict_subset_attrs.get(attr))
            self.assertFalse(overlapping_dict_attrs.get(attr))
        self.assertEqual(common_attrs['DEFINES'], {'UNICODE': True})
        self.assertEqual(dict_subset_attrs['DEFINES'], {})
        self.assertEqual(overlapping_dict_attrs['DEFINES'], {
            'DEBUG': True,
            'MOZ_DEBUG': True,
        })
Пример #11
0
 def test_single_attr_set(self):
     # If we only have one set of attributes they're all considered common.
     single_attrs = deepcopy(self.test_attrs)
     common_attrs = find_common_attrs([single_attrs])
     self.assertFalse(any(v for v in single_attrs.values()))
     self.assertEqual(self.test_attrs, common_attrs)
Пример #12
0
 def test_single_attr_set(self):
     # If we only have one set of attributes they're all considered common.
     single_attrs = deepcopy(self.test_attrs)
     common_attrs = find_common_attrs([single_attrs])
     self.assertFalse(any(v for v in single_attrs.values()))
     self.assertEqual(self.test_attrs, common_attrs)