Skip to content

Commit

Permalink
Update test_scheduler.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Arellano committed Oct 10, 2019
1 parent 62346b8 commit a889c72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion tests/python/pants_test/engine/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ python_tests(
'src/python/pants/base:cmd_line_spec_parser',
'src/python/pants/build_graph',
'src/python/pants/engine:scheduler',
'src/python/pants/util:objects',
'tests/python/pants_test/engine/examples:scheduler_inputs',
'tests/python/pants_test:test_base',
]
Expand Down
16 changes: 8 additions & 8 deletions tests/python/pants_test/engine/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from contextlib import contextmanager
from dataclasses import dataclass
from textwrap import dedent
from typing import List

from pants.engine.native import Native
from pants.engine.rules import RootRule, UnionRule, rule, union
from pants.engine.scheduler import ExecutionError, SchedulerSession
from pants.engine.selectors import Get, Params
from pants.util.objects import datatype
from pants_test.engine.util import assert_equal_with_printing, remove_locations_from_traceback
from pants_test.test_base import TestBase

Expand Down Expand Up @@ -145,12 +145,13 @@ def c_unhashable(_: TypeCheckFailWrapper) -> C:
yield C()


class CollectionType(datatype(['items'])):
pass
@dataclass(frozen=True)
class CollectionType:
items: List[int]


@rule
def c_unhashable_datatype(_: CollectionType) -> C:
def c_unhashable_dataclass(_: CollectionType) -> C:
# This `yield` would use the `nested_raise` rule, but it won't get to the point of raising since
# the hashability check will fail.
_ = yield Get(A, B, list()) # noqa: F841
Expand Down Expand Up @@ -254,7 +255,7 @@ def rules(cls):
RootRule(CollectionType),
a_typecheck_fail_test,
c_unhashable,
c_unhashable_datatype,
c_unhashable_dataclass,
nested_raise,
]

Expand Down Expand Up @@ -283,9 +284,8 @@ def assert_has_end_of_cffi_extern_error_traceback(exc_str):
return c.identify(obj)
File LOCATION-INFO, in identify
hash_ = hash(obj)
File LOCATION-INFO, in __hash__
.format(self, type(self).__name__, field_name, e))
TypeError: For datatype object CollectionType(items=[1, 2, 3]) (type 'CollectionType'): in field 'items': unhashable type: 'list'
File "<string>", line 2, in __hash__
TypeError: unhashable type: 'list'
"""), exc_str, "exc_str was: {}".format(exc_str))

resulting_engine_error = dedent("""\
Expand Down

0 comments on commit a889c72

Please sign in to comment.