From e5bd7fb0530efa49e5ca7d5fcd9fd741968226b0 Mon Sep 17 00:00:00 2001
From: Bruno Oliveira <bruno@esss.com.br>
Date: Mon, 2 Dec 2019 15:18:04 -0300
Subject: [PATCH] Convert pytest.py into a package

As discussed in https://github.com/pytest-dev/pytest/issues/3342, this
is the first step to make pytest support static typing fully
---
 setup.cfg                             |  2 +-
 src/{pytest.py => pytest/__init__.py} | 13 +++----------
 src/pytest/__main__.py                |  7 +++++++
 3 files changed, 11 insertions(+), 11 deletions(-)
 rename src/{pytest.py => pytest/__init__.py} (90%)
 create mode 100644 src/pytest/__main__.py

diff --git a/setup.cfg b/setup.cfg
index 42d5b9460..54b64af96 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -38,8 +38,8 @@ packages =
     _pytest.assertion
     _pytest.config
     _pytest.mark
+    pytest
 
-py_modules = pytest
 python_requires = >=3.5
 
 [options.entry_points]
diff --git a/src/pytest.py b/src/pytest/__init__.py
similarity index 90%
rename from src/pytest.py
rename to src/pytest/__init__.py
index b934e65cb..7b79603af 100644
--- a/src/pytest.py
+++ b/src/pytest/__init__.py
@@ -4,6 +4,7 @@ pytest: unit and functional testing with Python.
 """
 from _pytest import __version__
 from _pytest.assertion import register_assert_rewrite
+from _pytest.compat import _setup_collect_fakemodule
 from _pytest.config import cmdline
 from _pytest.config import hookimpl
 from _pytest.config import hookspec
@@ -93,14 +94,6 @@ __all__ = [
     "yield_fixture",
 ]
 
-if __name__ == "__main__":
-    # if run as a script or by 'python -m pytest'
-    # we trigger the below "else" condition by the following import
-    import pytest
 
-    raise SystemExit(pytest.main())
-else:
-
-    from _pytest.compat import _setup_collect_fakemodule
-
-    _setup_collect_fakemodule()
+_setup_collect_fakemodule()
+del _setup_collect_fakemodule
diff --git a/src/pytest/__main__.py b/src/pytest/__main__.py
new file mode 100644
index 000000000..01b2f6ccf
--- /dev/null
+++ b/src/pytest/__main__.py
@@ -0,0 +1,7 @@
+"""
+pytest entry point
+"""
+import pytest
+
+if __name__ == "__main__":
+    raise SystemExit(pytest.main())