-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cirq.testing.assert_same_diagram. #917
Conversation
4320668
to
cf3f800
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is exactly what I had in mind! Just a few comments.
It looks like |
Python 2 has izip_longest. Is there a way to specify this should be used during the transpilation? |
We could search replace |
100a137
to
32ea3fe
Compare
Hmm, it seems I can't use |
7d39868
to
2feecd4
Compare
Where is that being triggered? In general, we try to make sure unicode works even in python 2. |
In (btw is there a way to specify running a specific test when running the python2 virtual environment using |
2feecd4
to
e056b3d
Compare
Strings don't automatically handle unicode in python2 so we'd have to change the test for python2 (and change I've marked the test |
cb55399
to
e056b3d
Compare
So one way I can fix this is to wrap the |
It doesn't make sense that this specific test would have a failure when all the other ones work fine. We do quite a lot of tests involving unicode strings! There is something unique about this one that I don't understand that is triggering the issue. |
It's something to do with |
Here's my current workaround: with pytest.raises(AssertionError) as ex_info:
cirq.testing.assert_has_diagram(circuit, u"""
0: ───@───
│
1: ───Z───
""")
assert expected_error in ex_info.value.args[0] |
This is a very strangely behaved thing. This passes: with pytest.raises(AssertionError, match=u'█'.encode('utf-8')):
raise AssertionError(u'█'.encode('utf-8')) Whereas this fails: with pytest.raises(AssertionError, match=u'█'.encode('utf-8')):
assert False, u'█'.encode('utf-8') |
Could be a bug in pytest. It looks similar to this one: pytest-dev/pytest#877 |
I've added a commit with your work around. (btw is there a way to do a diffbase in github, i.e., work on top of an uncommitted PR? This particular change is super useful for doing other stuff, e.g., #918.) |
The closest thing is to create a PR that merges into the other branch. Unfortunately, this means that none of the branch protections kick in (e.g. requiring a review, running status checks). |
Automerge: started |
Automerge done. |
Fixes #830.