1. 16 3月, 2018 1 次提交
  2. 15 3月, 2018 4 次提交
  3. 14 3月, 2018 6 次提交
  4. 13 3月, 2018 3 次提交
    • C
      avocado/core/tree.py: allow MuxTreeNode to be hashed under Python 3 · 3d41ea15
      Cleber Rosa 提交于
      Under Python 3, as in Python 2, most objects are automatically
      hashable.  Example:
      
         >>> class Foo(object):
         >>>     pass
         >>> hash(Foo())
         >>> 8760583602380
      
      But if an object that implements __eq__ also has to implement
      __hash__.  Under Python 3:
      
         >>> class Foo(object):
         >>>     def __eq__(self, other):
         >>>         return False
         Traceback (most recent call last):
         File "<stdin>", line 1, in <module>
         TypeError: unhashable type: 'Foo'
      
      Since TreeNode implements __eq__, under Python 3, it *must* implement
      __hash__.  There are a few tricky points, though.  One of them is that
      "The only required property is that objects which compare equal have
      the same hash value".  TreeNodes have a very flexible equality
      comparison, which cannot be taken into account in a hash
      implementation which doesn't have access to the "other" object.
      
      To the best of my knowledge, the way to go with the TreeNode __hash__
      implementation is to take into account the comparison of all
      attributes that are used on __eq__ (name, values, children) and use
      those as the composition for __hash__, as suggested by the Python
      docs.  Unfortunately, some of the content of "values" and "children"
      may themselves be unshashable values (such as dicts coming from YAML
      test suite loader).  My coward's way out here was to use a string
      representation of such unhashable types to compose the TreeNode hash.
      
      This fixes 5 unittests of the varianter_yaml_to_mux plugin when
      run under Python 3, such as:
      
          ======================================================================
          ERROR: test_get_rel_path (tests.test_mux.TestAvocadoParams)
          ----------------------------------------------------------------------
            ....
              if len(set([_[1] for _ in ret])) == 1:  # single source of results
          TypeError: unhashable type: 'MuxTreeNode'
      
      Reference: https://docs.python.org/3/reference/datamodel.html#object.__hash__Signed-off-by: NCleber Rosa <crosa@redhat.com>
      3d41ea15
    • C
      test_fingerprint_order: work around dict items representation · 27656da5
      Cleber Rosa 提交于
      In Python 3, the order of a dictionary items will be different than
      under Python 2.  To not have to change the supporting code to return
      OrderedDicts, let's just simplify the comparison, breaking them down
      into each dictionary item.
      
      This fixes the varianter_yaml_to_mux plugin unittest failure under
      Python 3:
      
          ======================================================================
          FAIL: test_fingerprint_order (tests.test_mux.TestMuxTree)
          ----------------------------------------------------------------------
          Traceback (most recent call last):
            File "/home/cleber/src/avocado/avocado/optional_plugins/varianter_yaml_to_mux/tests/test_mux.py", line 231, in test_fingerprint_order
              self.assertEqual(str(variant1), "{'paths': '', 'variant': "
          AssertionError: "{'variant_id': 'child1-child2-9154', 'varia[65 chars] ''}" != "{'paths': '', 'variant': [TreeNode(name='ch[65 chars]54'}"
          - {'variant_id': 'child1-child2-9154', 'variant': [TreeNode(name='child1'), TreeNode(name='child2')], 'paths': ''}
          + {'paths': '', 'variant': [TreeNode(name='child1'), TreeNode(name='child2')], 'variant_id': 'child1-child2-9154'}
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      27656da5
    • C
      selftests/functional/test_json_variants.py: do not rely on the order of dict · 46c96800
      Cleber Rosa 提交于
      The items of a dictionary are not ordered by default, and between
      Python 2 and 3 they always come out different in my experience.
      
      Since this test is trying out the representation of a JSON built from
      dicts, the same applies.  Let's make the checks a bit more flexible
      (and a bit less accurate to be honest) and check for the pieces of
      info inside the JSON file content.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      46c96800
  5. 12 3月, 2018 2 次提交
  6. 09 3月, 2018 8 次提交
  7. 08 3月, 2018 10 次提交
  8. 06 3月, 2018 1 次提交
  9. 01 3月, 2018 2 次提交
  10. 28 2月, 2018 3 次提交