Skip to content

[WIP] Tests without builtins fixtures - #3189

Closed
pkch wants to merge 13 commits into
python:masterfrom
pkch:nostubs
Closed

pkch wants to merge 13 commits into
python:masterfrom
pkch:nostubs

Conversation

@pkch

@pkch pkch commented Apr 18, 2017 •

Copy link
Copy Markdown
Contributor

Based on #3111. I am using this PR to examine the impact of removing builtins fixtures (# of failing tests and performance impact).

@pkch
pkch force-pushed the nostubs branch 2 times, most recently from 809baf6 to 632e780 Compare April 20, 2017 05:21
@pkch

pkch commented Apr 20, 2017 •

Copy link
Copy Markdown
Contributor Author

When env. var. NO_BUILTINS_FIXTURES is present and evaluates to True (using `os.environ['NO_BUILTINS_FIXTURES']), the tests run without fixtures.

On this branch, the tests run without fixtures on Travis / python 3.6, and the usual way in every other configuration.

For no-fixture tests, I temporarily disabled units tests for testsemanal, testtypegen and testtransform because they kept parsing too many modules. In addition, I disabled pytest testfinegrained because it has not implemented enough functionality yet to parse real stdlib modules. The only other tests that fail are under pytest.

When NO_BUILTINS_FIXTURES is enabled, differences in error messages are ignored if the expected and actual messages are on the same lines. In addition, duplicate messages on the same line are removed. The idea is that those things are not important to fix (or at very lower priority).

The current status for pytest (I'll update it as problems are resolved on master): 9 failed, 2415 passed.

I fixed everything that requires just minor edits to tests. The rest requires merging some PR referenced from #3111.

@pkch
pkch force-pushed the nostubs branch 2 times, most recently from f9a7cfa to 60ba056 Compare April 20, 2017 13:29
pkch added 3 commits April 20, 2017 07:01
* Env. var. NO_BUILTINS_FIXTURES=1 triggers using regular version for tests
* If NO_BUILTINS_FIXTURES=1, minor test error message differences are ignored
* Travis under python 3.6 build will run tests without fixtures
@pkch pkch changed the title [WIP] Benchmarking tests without builtins fixtures Tests without builtins fixtures Apr 20, 2017
@pkch pkch changed the title Tests without builtins fixtures [WIP] Tests without builtins fixtures Apr 20, 2017
@pkch
pkch force-pushed the nostubs branch 3 times, most recently from aa46617 to b070899 Compare April 25, 2017 11:22
[builtins fixtures/dict.pyi]

[case testNoReturnImportFromTyping]
from typing import NoReturn

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not right. If it fails, then typeshed should be updated, this is why this test is called testNoReturnImportFromTyping.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But python runtime would crash on that. Why would we want to allow it in mypy?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NoReturn is in typing now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I'm on python 3.6.0 so didn't realize that haha

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, you mean typing.NoReturn is in cpython master right? It's not yet in 3.6.1. I think it's fine for mypy to allow things that are valid on cpython master.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be included in 3.6.2

[case testTypeCheckNamedModule]
# cmd: mypy -m m.a
[file m/__init__.py]
None + 1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you replace None with object() everywhere? This does not seem right.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only replaced the cases where the intent is to check whether mypy gets to a given line. The test basically assumes that None + 1 will cause type error. But they don't fail because --strict-optional isn't the default. object() + 1 will fail under any conditions, so I thought I'd use it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, some tests are actually run with automatic addition of --strict-optional flag. Why this changes with your PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't change.

But apart from flags added to tests, and tests inside typeshed, and mypy mypy tests, I can't find tests that have automatic strict-optional. Are you sure it was done to the pytest tests?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure it was done to the pytest tests?

I am not, but I assumed this, since the tests were passing before, i.e. were giving an error for None + 1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was just because in the builtins fixture int.__radd__ isn't defined (only int.__add__). And the subtyping is only checked for the rhs, not for the lhs of these operators.


x = foo()
x = 1
x = x + 1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for this change? This looks strange.

@pkch pkch Apr 25, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of #3122. This test doesn't actually care about that behavior, it simply wanted to see if x + 1 is allowed. But until #3122 is fixed, the side effect is that x changes type in a inconsistent manner without fixtures - making the test fail.

@pkch pkch changed the title [WIP] Tests without builtins fixtures Tests without builtins fixtures Apr 25, 2017
@pkch

pkch commented Apr 25, 2017

Copy link
Copy Markdown
Contributor Author

The main purpose of this PR is to allow everyone to run no-fixtures tests locally by setting NO_BUILTINS_FIXTURES env. var. I removed the Travis setting that made this happen automatically.

@pkch

pkch commented Apr 25, 2017

Copy link
Copy Markdown
Contributor Author

After you review, I was going to rebase this off the current master to make it less likely to cause weird merge conflicts.

@pkch pkch changed the title Tests without builtins fixtures [WIP] Tests without builtins fixtures Apr 27, 2017
@pkch

pkch commented Apr 27, 2017

Copy link
Copy Markdown
Contributor Author

This PR has a lot of old stuff that would make merging it very messy. I'm closing this in favor of #3268. @ilevkivskyi I'm not just rebasing on master within this PR because you were reviewing it, and you'll lose the context if I do so.

@pkch pkch closed this Apr 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants