Skip to content
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

Convert all test cases to pytest #202

Merged
merged 329 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
329 commits
Select commit Hold shift + click to select a range
9f85a15
Update manpage.rst
pepoluan Nov 20, 2020
a2066ca
Remove list of Optional Arguments from cli.rst
pepoluan Nov 20, 2020
607dd69
Change faqs.org links to tools.ietf.org
pepoluan Nov 20, 2020
21afaad
Apply the boldital rule to SMTP parameters list
pepoluan Nov 20, 2020
f1b7a99
Use get_controller instead of ExposingController
pepoluan Nov 20, 2020
283ad5b
Correct controller usage of test_debugging_bytes
pepoluan Nov 20, 2020
6270a91
Add missing & lacking test cases
pepoluan Nov 20, 2020
53533cc
Renaming & moving test cases
pepoluan Nov 20, 2020
ce6fd20
Assign version: 1.2.3a3
pepoluan Nov 20, 2020
952e47d
Early exit on Travis CI.
pepoluan Nov 20, 2020
c5ff4ae
Add .pytest_cache to superclean
pepoluan Nov 20, 2020
344386f
Update README.rst
pepoluan Nov 20, 2020
8bd5f1a
Correct program name in main.py
pepoluan Nov 20, 2020
1723451
Some visual improvements
pepoluan Nov 20, 2020
75ec0ba
Fix qa complain
pepoluan Nov 20, 2020
9880b2d
Pass-through TRAVIS and CI env-vars
pepoluan Nov 20, 2020
766c755
Check on CI env-var as well
pepoluan Nov 21, 2020
d9dcaa9
Move stuff around
pepoluan Nov 22, 2020
d460da8
Explicit test for eof_received
pepoluan Nov 22, 2020
22fc1ab
Update README.rst
pepoluan Nov 22, 2020
3a40153
Fix missing StreamReaderProtocol
pepoluan Nov 22, 2020
d10441e
Rewrite links using standard directives
pepoluan Nov 22, 2020
2eb95b8
Invoke eof_received() from handler
pepoluan Nov 22, 2020
5def612
Remove leftover underlines
pepoluan Nov 22, 2020
d634fab
Remove #pragma:nomswin for line 247.
pepoluan Nov 22, 2020
4cc0bcc
Bump Version
pepoluan Nov 22, 2020
5b7482c
Remove test.yml + INTENTIONAL FAIL
pepoluan Nov 23, 2020
c868b44
Change over to GitHub Actions
pepoluan Nov 23, 2020
7386001
Revert intentional fail
pepoluan Nov 23, 2020
9a1b0c5
First, delete test.yml ...
pepoluan Nov 23, 2020
3e27ab3
Use --strict-markers
pepoluan Nov 24, 2020
3aa2199
Move class def to the proper region
pepoluan Nov 24, 2020
5699904
Explain in more details on how to implement from_cli()
pepoluan Nov 24, 2020
46a4f22
Improve general formatting of handlers.rst
pepoluan Nov 24, 2020
82955ae
handlers.rst: Better formatting + CLI examples
pepoluan Nov 24, 2020
d8b4904
Add docstring to test_1packaging.py
pepoluan Nov 25, 2020
0e26566
test_starttls.py: Put orphan test case in a class
pepoluan Nov 25, 2020
b9d32f9
test_starttls.py: Remove literal SMTP responses
pepoluan Nov 25, 2020
6995d90
test_starttls.py: Add comment for try..except
pepoluan Nov 25, 2020
b9d04c2
conftest.py: Add fixture: nodecode_controller
pepoluan Nov 25, 2020
23aa4e6
Fix and add docstring and formatting
pepoluan Nov 25, 2020
cd88386
Apply SSOT principle to test_handlers.py
pepoluan Nov 25, 2020
b5610a0
test_handlers.py: Improve FakeParser implementation
pepoluan Nov 25, 2020
d67e319
test_handlers.py: Simplify testing of proxy
pepoluan Nov 25, 2020
9513824
test_handlers.py: General improvement
pepoluan Nov 25, 2020
1eb4552
Add test for monotonic versioning
pepoluan Dec 1, 2020
67d206b
Add test for version desc in NEWS.rst
pepoluan Dec 1, 2020
8c30893
Split command before passing to check_output
pepoluan Dec 3, 2020
725929c
Partial-Merge tox.ini from master
pepoluan Dec 24, 2020
fe5dabb
Merge housekeep.py from master
pepoluan Dec 24, 2020
b6d6247
Merge .coveragerc from master
pepoluan Dec 24, 2020
1141a7c
Merge GitHub Actions from master
pepoluan Dec 24, 2020
23e9f8e
Merge smtp.py from master
pepoluan Dec 24, 2020
e7bec6d
Grab some changes from master
pepoluan Jan 3, 2021
c09d458
Rename .coveragerc to coverage.cfg
pepoluan Dec 31, 2020
b29d660
Add exclusion for PyCharm helpers
pepoluan Jan 3, 2021
e5478ba
Grab doc changes from master
pepoluan Jan 3, 2021
6e7668b
Merge some smtp.py changes from master
pepoluan Jan 3, 2021
43755f8
Merge some controller.py changes from master
pepoluan Jan 3, 2021
37be1f0
Grab newer lmtp.py from master
pepoluan Jan 3, 2021
4867719
Merge branch 'master' into pytest_based
pepoluan Jan 3, 2021
3be1721
Change to pure setup.cfg-based installation
pepoluan Dec 31, 2020
d6ea672
Transition from pytest.ini to pyproject.toml
pepoluan Jan 3, 2021
0b12e7d
Fold coverage.py config into pyproject.toml
pepoluan Jan 3, 2021
376513f
Remove unused .appveyor.yml file
pepoluan Jan 3, 2021
717c0eb
Comment on why flake8 still has its config in tox.ini
pepoluan Jan 3, 2021
257dc03
Sanitize client-sent command line
pepoluan Jan 17, 2021
24f7cfc
Add facility to activate logging for test_smtp
pepoluan Jan 17, 2021
cfc242b
Provide an easier-to-read return_value for get_extra_info
pepoluan Jan 17, 2021
a311892
Provide an easier-to-read repr for _Missing
pepoluan Jan 17, 2021
cb8dd56
Add ignore for ~temp*
pepoluan Jan 17, 2021
918d55e
Add optional and default disabled logging for AUTH
pepoluan Jan 17, 2021
e07b3c1
Bugfix: Should have used logging.INFO instead of "INFO"
pepoluan Jan 17, 2021
f8cd922
Do direct tuple comparison
pepoluan Jan 17, 2021
11d40b9
Ensure warning raised on log_client_response=True
pepoluan Jan 17, 2021
14f1f8e
Update NEWS.rst
pepoluan Jan 17, 2021
dd3b131
Version Bump to 1.2.4a1
pepoluan Jan 17, 2021
4a7d7f9
Annotate the complex-looking regex
pepoluan Jan 19, 2021
4cd296c
Merge branch 'master' into hide-password-in-logs
pepoluan Jan 19, 2021
d9fe241
Fix Bug due to merging
pepoluan Jan 19, 2021
8201665
Remove setup_helpers.py
pepoluan Jan 20, 2021
e9c691b
Fix readthedocs doc building
pepoluan Jan 20, 2021
de0bb31
Improve housekeep.py
pepoluan Jan 20, 2021
c029e5c
Include *.toml in MANIFEST
pepoluan Jan 20, 2021
0050cd4
Improve README.rst
pepoluan Jan 20, 2021
cc78848
Update (merge) docs from master
pepoluan Jan 20, 2021
b4d8c38
Improve kwargs handling
pepoluan Jan 20, 2021
c6ac674
Merge lmtp.py from master
pepoluan Jan 20, 2021
cee54cf
Merge smtp.py from master
pepoluan Jan 20, 2021
be7f65c
Merge release.py from master
pepoluan Jan 20, 2021
e8a6ce5
Rename server_kwargs attribute to SMTP_kwargs
pepoluan Jan 20, 2021
c7ab35e
Update controller.rst
pepoluan Jan 20, 2021
82439c4
Add Extended Status Code for 501 Auth Aborted
pepoluan Jan 21, 2021
b92142a
Change default logic for get_handler()
pepoluan Jan 21, 2021
ecc317b
Add docstrings to explain the difference
pepoluan Jan 21, 2021
751df90
Merge "tests of questionable values" into similar ones
pepoluan Jan 21, 2021
b56bb3d
SO MANY CHANGES...
pepoluan Jan 21, 2021
292d08c
Merge Bugfix: Fix assert for LHLO response
pepoluan Jan 21, 2021
bea866c
Convert test_smtp::TestAuthArgs into pytest-based
pepoluan Jan 21, 2021
5a91003
Black-ification
pepoluan Jan 21, 2021
40bf400
Remove save_log_level fixture
pepoluan Jan 22, 2021
062c33a
Convert TestFactory from master into pytest
pepoluan Jan 22, 2021
8880749
Use direct server_kwargs
pepoluan Jan 22, 2021
0104a97
Use direct tuple comparison
pepoluan Jan 22, 2021
b5c2e60
Annotate mocker as MockFixture
pepoluan Jan 22, 2021
6ca6b17
Convert rest of tests in test_smtp.py to pytest
pepoluan Jan 22, 2021
ed0e21e
Convert rest of tests in test_starttls.py to pytest
pepoluan Jan 22, 2021
6ca3fdb
Fix qa complaints
pepoluan Jan 22, 2021
e099e4b
Add AUTH mechanisms with dash(es)
pepoluan Jan 22, 2021
27a8433
Add one missing test
pepoluan Jan 22, 2021
f5fb356
Try to workaround LGTM.com false positive
pepoluan Jan 22, 2021
a7d47bf
Add test case to ensure log sanitizing for AUTH
pepoluan Jan 22, 2021
0555b05
Implement sanitized_log function
pepoluan Jan 22, 2021
f8fadb6
Merge branch 'hide-password-in-logs' into pytest_based
pepoluan Jan 22, 2021
af1442c
Convert hide-password-in-logs test cases to pytest
pepoluan Jan 22, 2021
d03e0d5
Try adding MacOS
pepoluan Jan 23, 2021
f748fef
Workaround for funky FQDNs
pepoluan Jan 23, 2021
127c21a
Move suppress_userwarning fixture to conftest.py
pepoluan Jan 23, 2021
4eebc42
Add server_hostname kwarg to Controller
pepoluan Jan 23, 2021
4f1621f
Add test case for server_hostname
pepoluan Jan 23, 2021
f9d0e27
Add test case for unknown kwarg in server_kwargs
pepoluan Jan 23, 2021
f1fc12c
Apply supprss_allwarnings on test_enablesmtputf8_flag
pepoluan Jan 23, 2021
677c9d5
Limit GA triggering events
pepoluan Jan 23, 2021
d0efcc3
Split qa & docs into a separate GA job
pepoluan Jan 23, 2021
267aa92
Merge branch 'master' into pytest_based
pepoluan Jan 23, 2021
8d448c2
BUGFIX: Typo
pepoluan Jan 23, 2021
ee842db
Move meta tests to aiosmtpd/qa, and execute in qa
pepoluan Jan 23, 2021
330e91e
Include .py files in project root
pepoluan Jan 23, 2021
ef4bdd6
Blackify conf.py
pepoluan Jan 23, 2021
56562cf
Update NEWS.rst, _purposefully_ wrongly
pepoluan Jan 23, 2021
2876245
Use short tb for qa pytest
pepoluan Jan 23, 2021
1d422b5
Fix NEWS.rst
pepoluan Jan 23, 2021
071a5e1
Exclude qa and docs from coverage
pepoluan Jan 23, 2021
cb89039
Rename bpo27931 test cases to reflect master
pepoluan Jan 23, 2021
64ad916
Merge branch 'master' into pytest_based
pepoluan Jan 24, 2021
9d7f4c0
Add tip about .python-version
pepoluan Jan 26, 2021
eb1c59b
Try tox-less GA
pepoluan Jan 27, 2021
039f425
Merge branch 'master' into pytest_based
pepoluan Jan 27, 2021
602001c
Set PY_36 env var
pepoluan Jan 27, 2021
fbbb197
Fold "windows-latest" into matrix proper
pepoluan Jan 27, 2021
8cc34b7
Exclude GA's "hostedtoolcache" dir
pepoluan Jan 27, 2021
709406c
Remove platform from matrix
pepoluan Jan 27, 2021
6365656
Update location of hostedtoolcache
pepoluan Jan 27, 2021
36b4536
Force usage of bash
pepoluan Jan 27, 2021
1e15258
Set fetch-depth to 0
pepoluan Jan 27, 2021
34cc729
Remove --tb=short
pepoluan Jan 27, 2021
b0d603c
Fix annotation according to pytype findings
pepoluan Jan 27, 2021
f9440da
Disable import-error on colorama import
pepoluan Jan 27, 2021
126eec7
Fix annotations according to pytype finding
pepoluan Jan 27, 2021
94f635f
Fix annotations according to pytype finding
pepoluan Jan 27, 2021
4520639
Add exclusion for Sphinx extensions
pepoluan Jan 27, 2021
ca0cb1f
Fix annotations according to pytype hints
pepoluan Jan 27, 2021
62fce82
Fix pytype typo
pepoluan Jan 27, 2021
468fd09
Fix Generator[] annotation typos
pepoluan Jan 27, 2021
80fe196
Fix annotations according to pytype hints
pepoluan Jan 27, 2021
b0878ff
Disable not-supported-yet warnings/alerts in setup.cfg
pepoluan Jan 27, 2021
5df6415
Fix annotations according to pytype hints
pepoluan Jan 27, 2021
6c946f2
Fix annotations according to pytype hints
pepoluan Jan 28, 2021
ff31cb1
Fix annotations according to pytype hints
pepoluan Jan 28, 2021
d01e0ae
Activate pytype checking in GA yml
pepoluan Jan 28, 2021
63bf8ce
Add pytest-mock to qa_docs job
pepoluan Jan 28, 2021
ac7af50
Add NOTICE to MANIFEST.in
pepoluan Jan 28, 2021
13ecefd
Add check-manifest to QA steps
pepoluan Jan 28, 2021
af05769
Indicate that we provide type hints
pepoluan Jan 28, 2021
6c1abaa
Merge branch 'master' into pytest_based
pepoluan Jan 28, 2021
7a69afd
Add Apache-2.0 snippets
pepoluan Jan 28, 2021
9f06f0e
Pass constructor args & kwargs to get_handler
pepoluan Jan 28, 2021
55cec6b
Test Cases for new & old EHLO hook
pepoluan Jan 28, 2021
39bd52e
Change test_handlers to be more pytest-ic
pepoluan Jan 29, 2021
7c432c8
Use pytest.raises(match) instead of manually seeking
pepoluan Jan 29, 2021
1d25613
Silence some PytestUnraisableExceptionWarning warnings
pepoluan Jan 29, 2021
7c799b5
Suppress _ProactorBasePipeTransport exception
pepoluan Jan 29, 2021
4305c7a
Suppress DeprecationWarning for EHLO hook
pepoluan Jan 29, 2021
0150ffd
Suppress UserWarning the right way
pepoluan Jan 29, 2021
312e78c
Suppress DeprecationWarning the right way...
pepoluan Jan 29, 2021
b436499
Move silence_event_loop_closed fixture to conftest.py
pepoluan Jan 29, 2021
b995cc6
Suppress PytestUnraisableExceptionWarning
pepoluan Jan 29, 2021
17a7cee
QA: Remove no-longer-used context manager vars
pepoluan Jan 29, 2021
e353318
Exclude line from pytype inspection
pepoluan Jan 29, 2021
9184149
Shorten expected regex
pepoluan Jan 29, 2021
45d2b17
Merge branch 'master' into pytest_based
pepoluan Jan 29, 2021
47402af
Black-ification
pepoluan Jan 29, 2021
4047269
Disable pytype import-error for colorama
pepoluan Jan 29, 2021
052dd49
Change Deprecation Notice to "warning" block
pepoluan Jan 29, 2021
77f5456
Better docstring
pepoluan Jan 30, 2021
22ff4b0
Merge branch 'master' into pytest_based
pepoluan Jan 30, 2021
bde7a62
Add Fira Code to the list of monospace fonts
pepoluan Jan 30, 2021
b118b69
Remove conf.py from GA yml flake8
pepoluan Jan 30, 2021
a4782c2
Add another "language injection" directive
pepoluan Jan 31, 2021
7177552
Merge branch 'master' into pytest_based
pepoluan Jan 31, 2021
a2ecba2
Remove explicit conf.py flake8 test
pepoluan Jan 31, 2021
99877cb
Convert new tests to pytest
pepoluan Jan 31, 2021
dabe3a9
Change how get_controller() fixture works
pepoluan Jan 31, 2021
a3b6f44
Add docstring to StatusCode methods
pepoluan Jan 31, 2021
fbb03fc
Add disabled code for checking out mail.log
pepoluan Jan 31, 2021
6c047af
Explicitly show XPASS results
pepoluan Jan 31, 2021
59ee8c4
Reduce clutter by using --tb=short
pepoluan Jan 31, 2021
f7c17c3
Install pickle5 only for python < 3.8
pepoluan Jan 31, 2021
4114954
Change how get_handler() works
pepoluan Feb 1, 2021
75a2167
Add important remarks to conftest.py
pepoluan Feb 1, 2021
4fda849
Remove 2 'simple' fixtures from test_handlers.py
pepoluan Feb 1, 2021
baa8d71
Rename test_smtp.authenticator to .auth_callback
pepoluan Feb 1, 2021
c926b28
Simplify controller used in TestSMTP
pepoluan Feb 1, 2021
460b02a
Remove dead code
pepoluan Feb 1, 2021
8017323
Simplify test case signatures
pepoluan Feb 1, 2021
ce6aff9
Remove strictascii_controller
pepoluan Feb 1, 2021
e063618
Remove fixture require_auth_controller
pepoluan Feb 1, 2021
cfe636e
Add very important comment in test_smtp.py
pepoluan Feb 1, 2021
71188bf
Simplify sys.path.insert
pepoluan Feb 1, 2021
e833beb
Change internal workings of get_controller and get_handler
pepoluan Feb 1, 2021
a0e916c
Remove ExposingController and create aliases for markers
pepoluan Feb 1, 2021
471a547
Set temporary (alpha) version
pepoluan Feb 1, 2021
09c63f1
Merge branch 'master' into pytest_based
pepoluan Feb 1, 2021
076bf65
Remove pickle5 from list of deps
pepoluan Feb 1, 2021
325186c
Add testing.rst
pepoluan Feb 2, 2021
da33804
Switch to "sphinx_rtd_theme" for HTML theme
pepoluan Feb 2, 2021
ae8be08
Suppress "unused import" error
pepoluan Feb 2, 2021
d58cafe
Add sphinx_rtd_theme to deps of the "Docs Checking" step
pepoluan Feb 2, 2021
7a40f5a
Increase verbosity for pytest in qa & docs
pepoluan Feb 2, 2021
c86a151
Disable capsys during git to see output
pepoluan Feb 2, 2021
d73de8a
Checkout master in GA
pepoluan Feb 2, 2021
485f6a2
fetch origin/master
pepoluan Feb 2, 2021
15050e8
fetch using branch:branch instead of +refs:refs
pepoluan Feb 2, 2021
2ce058a
Also do fetch origin master:master before main job
pepoluan Feb 2, 2021
84d102a
Perform copy of markerdata
pepoluan Feb 3, 2021
6ff6e41
Configure for isort
pepoluan Feb 3, 2021
4a2ffc8
Apply isort + black to all test modules
pepoluan Feb 3, 2021
6103bfa
Apply isort to all aiosmtpd/*.py files
pepoluan Feb 3, 2021
bcc29f7
Apply isort to all ./*.py files
pepoluan Feb 3, 2021
67a41dc
Activate flake8-bugbear
pepoluan Feb 3, 2021
6b9ab76
Bugbear-hinted fixes
pepoluan Feb 3, 2021
d5514d5
Some minor changes hinted by mypy
pepoluan Feb 3, 2021
7a1ae79
Move __version__ to __init__.py
pepoluan Feb 5, 2021
04df50a
Tidying up using isort
pepoluan Feb 5, 2021
cf90cd3
Add Compatibility Test
pepoluan Feb 5, 2021
917b8c3
Update NEWS.rst
pepoluan Feb 5, 2021
97bd3b3
Merge branch 'version-in-init' into pytest_based
pepoluan Feb 5, 2021
fc4fd79
Convert TestCompat from version-in-init to pytest
pepoluan Feb 5, 2021
85a8e5a
Merge branch 'master' into pytest_based
pepoluan Feb 6, 2021
632afe1
Fix formatting in README.rst
pepoluan Feb 6, 2021
b569f0f
Try coverage-conditional 5
pepoluan Feb 6, 2021
2a878b1
Remove PLATFORM env var
pepoluan Feb 6, 2021
8e77d84
Make conditional pragma names to be uniform
pepoluan Feb 6, 2021
56b9d3e
Remove no longer used env vars from GA workflow
pepoluan Feb 6, 2021
762299a
Merge branch 'master' into pytest_based
pepoluan Feb 7, 2021
a8d1f43
Add comment about WSL detection
pepoluan Feb 7, 2021
e1ff7f8
Merge branch 'master' into pytest_based
pepoluan Feb 7, 2021
e426c11
Some improvements
pepoluan Feb 7, 2021
f3229c9
Apply Apache-2.0 license for qa tests
pepoluan Feb 7, 2021
e82ad38
Merge branch 'master' into pytest_based
pepoluan Feb 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 46 additions & 31 deletions .github/workflows/unit-testing-and-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,63 +23,78 @@ jobs:
qa_docs:
runs-on: ubuntu-20.04
steps:
- name: "Checkout latest commit"
- name: "Checkout latest PR commit"
uses: actions/checkout@v2
- name: "Set up Python 3.8"
- name: "Set up Python"
uses: actions/setup-python@v2
with:
# 3.8 is chosen because it seems to be the fastest for <3.9
# (3.9 excluded because it seems to be still very unstable)
python-version: 3.8
- name: "Install dependencies"
- name: "Update modules & install deps"
# language=bash
run: |
python -m pip install --upgrade pip
pip install tox
- name: "Execute tox -e qa,docs"
python -m pip install --upgrade pip setuptools wheel
python setup.py develop
- name: "flake8 Style Checking"
# language=bash
run: |
tox -e qa,docs
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"Unfolding" tox into separate, direct invocation of test stuff should make GA checks faster as the runner no longer has to first create virtualenvs.

The drawback is of course if the steps within tox.ini changes, we have to edit the GA steps as well, but I don't think we'll be changing them any time soon after this heavylift transition to pure pytest.

pip install colorama flake8
python -m flake8 aiosmtpd setup.py housekeep.py release.py
- name: "Docs Checking"
# language=bash
run: |
pip install colorama pytest pytest-mock sphinx sphinx-autofixture sphinx_rtd_theme
pytest -v aiosmtpd/docs
python setup.py build_sphinx
- name: "Static Type Checking"
# language=bash
run: |
pip install pytype
pytype --keep-going --jobs auto .
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will NOT add this into tox.ini because currently pytype does not run on Windows.

- name: "Other QA Checks"
# language=bash
run: |
pip install pytest pytest-mock check-manifest
git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin master:master
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This line is needed because actions/checkout@v2 pulls exactly commit, and the master branch -- needed by one of the qa tests -- was not created.

pytest -v aiosmtpd/qa
check-manifest -v
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice tool, this; anyone knows a similar tool to double-check package health prior to pushing to PyPI?

testing:
needs: qa_docs
strategy:
# If a matrix fail, do NOT stop other matrix, let them run to completion
fail-fast: false
matrix:
os: [ "ubuntu-18.04", "ubuntu-20.04", "macos-10.15" ]
platform: [ "posix" ]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Replaced with detection + env var setting in test step proper right before invoking pytest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

And it's now moot because we're using coverage-conditional-plugin

os: [ "ubuntu-18.04", "ubuntu-20.04", "macos-10.15", "windows-latest" ]
python-version: [ "3.6", "3.7", "3.8", "3.9", "pypy3" ]
include:
- os: "windows-latest"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's just run GA's Windows runner for all supported Python versions.

IIRC this "run just one version on Windows" decision stemmed from the need to be frugal with Travis CI minutes; GA's limits is quite lenient.

platform: "mswin"
# Only the latest frozen branch as indicated on
# https://devguide.python.org/#branchstatus
# ('frozen' means Status == "security")
# Reason being that Windows users can change their Python anytime,
# so there is no benefit in testing all released Python versions.
# Plus pypy3 implementation in Windows is ... complicated. We
# should stay away from all those complications; users choosing to
# run aiosmtpd on pypy3 on Windows should be considered advanced
# and know what they're doing.
python-version: "3.7"
runs-on: ${{ matrix.os }}
steps:
- name: "Checkout latest commit"
uses: actions/checkout@v2
with:
fetch-depth: 0 # Required by codecov/codecov-action@v1
- name: "Set up Python ${{ matrix.python-version }}"
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: "Install dependencies"
# language=bash
run: |
python -m pip install --upgrade pip
pip install tox
- name: "Execute tox"
env:
PLATFORM: ${{ matrix.platform }}
# "py" testenv means we'll use whatever Python provided by GA,
# as specified in 'matrix' above. No need to specify exact version.
python -m pip install --upgrade pip setuptools wheel
# Test deps
pip install colorama coverage[toml] coverage-conditional-plugin packaging pytest pytest-cov pytest-mock
# Package deps
python setup.py develop
# Fetch master because some test cases might need its existence
git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin master:master
- name: "Execute testing"
shell: bash
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, Windows Runners on GA do support bash

# language=bash
run: |
tox -e py-cov
pytest --cov --cov-report=xml --cov-report=term
- name: "Report to codecov"
# Ubuntu 18.04 came out of the box with 3.6, and LOTS of system are still running
# 18.04 happily, so we choose this as the 'canonical' code coverage testing.
# One day we'll have to revisit this and bump the version ...
if: always() && matrix.python-version == '3.6' && matrix.os == 'ubuntu-latest'
if: matrix.python-version == '3.6' && matrix.os == 'ubuntu-18.04'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Explicit pointing to ubuntu-18.04 because ubuntu-latest is transitioning to 20.04

uses: codecov/codecov-action@v1
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ parts
coverage
eggs
sources
build
build/
dist
venv
.installed.cfg
Expand Down Expand Up @@ -32,5 +32,6 @@ coverage-*.xml
diffcov.html
diffcov-*.html
.python-version
prof/
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the work directory for pytest-profiling.

.pytype/
~temp*
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
graft aiosmtpd
include LICENSE *.cfg *.ini *.py *.rst *.yml *.toml
include LICENSE NOTICE *.cfg *.ini *.py *.rst *.yml *.toml
global-exclude *.py[oc]
38 changes: 25 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ You can also add the ``-s``/``--capture=no`` option to show output, e.g.::

$ tox -e py36-nocov -- -s

and these options can be combined::

$ tox -e py36-nocov -- -x -s <testname>

(The ``-e`` parameter is explained in the next section about 'testenvs'.
In general, you'll want to choose the ``nocov`` testenvs if you want to show output,
so you can see which test is generating which output.)
Expand Down Expand Up @@ -194,23 +198,22 @@ have been configured and tested:

* ``docs``

Builds HTML documentation using Sphinx
Builds HTML documentation using Sphinx. A `pytest doctest`_ will run prior to
actual building of the documentation.


Environment Variables
-------------------------

``PLATFORM``
~~~~~~~~~~~~~~~~
``ASYNCIO_CATCHUP_DELAY``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Used on non-POSIX operating systems to specify tests to skip.
Valid values:
Due to how asyncio event loop works, some actions do not instantly get
responded to. This is especially so on slower / overworked systems.
In consideration of such situations, some test cases invoke a slight
delay to let the event loop catch up.

+-----------+-------------------------------------------------------+
| ``mswin`` | when running tox on Microsoft Windows (non-Cygwin) |
+-----------+-------------------------------------------------------+
| ``wsl`` | when running tox on Windows Subsystem for Linux (WSL) |
+-----------+-------------------------------------------------------+
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed because coverage-conditional-plugin already performs OS detection.

Defaults to `0.1` and can be set to any float value you want.


Different Python Versions
Expand All @@ -233,27 +236,36 @@ versions on your system by using ``pyenv``. General steps:
Python interpreter versions you want to make available to tox (see pyenv's
documentation about this file)

**Tip:** The 1st line of ``.python-version`` indicates your *preferred* Python version
which will be used to run tox.

5. Invoke tox with the option ``--tox-pyenv-no-fallback`` (see tox-pyenv's
documentation about this option)


``housekeep.py``
-------------------
----------------

If you ever need to 'reset' your repo, you can use the ``housekeep.py`` utility
like so::

$ python housekeep.py superclean

It is `strongly` recommended to NOT do superclean too often, though.
It is *strongly* recommended to NOT do superclean too often, though.
Every time you invoke ``superclean``,
tox will have to recreate all its testenvs,
and this will make testing `much` longer to finish.
and this will make testing *much* longer to finish.

``superclean`` is typically only needed when you switch branches,
or if you want to really ensure that artifacts from previous testing sessions
won't interfere with your next testing sessions.

For example, you want to force Sphinx to rebuild all documentation.
Or, you're sharing a repo between environments (say, PSCore and Cygwin)
and the cached Python bytecode messes up execution
(e.g., sharing the exact same directory between Windows PowerShell and Cygwin
will cause problems as Python becomes confused about the locations of the source code).


License
=======
Expand Down
7 changes: 6 additions & 1 deletion _static/aiosmtpd.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ div.body h4 {
}

.pre, pre, code {
font-family: Menlo,Consolas,"Ubuntu Mono",Inconsolata,"Bitstream Vera Sans Mono","lucida console","Courier New",monospace;
font-family: "Fira Code",Menlo,Consolas,"Ubuntu Mono",Inconsolata,"Bitstream Vera Sans Mono","lucida console","Courier New",monospace;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm a great big fan of the Fira Code open-source font and I think everyone should use that :D

font-size: 90%;
}

div.highlight pre {
Expand All @@ -51,3 +52,7 @@ div#news-for-aiosmtpd h3 {
em.sig-param > span.default_value, em.sig-param > span.o {
color: rgb(128, 128, 128);
}

a {
text-decoration: underline dotted !important;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The sphinx_rtd_theme is confusing differing between pre spans and pre-within-a.

2 changes: 1 addition & 1 deletion aiosmtpd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2014-2021 The aiosmtpd Developers
# SPDX-License-Identifier: Apache-2.0

__version__ = "1.3.0a4"
__version__ = "1.3.0a9"
1 change: 0 additions & 1 deletion aiosmtpd/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from aiosmtpd.main import main


if __name__ == '__main__':
main()
59 changes: 34 additions & 25 deletions aiosmtpd/controller.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Copyright 2014-2021 The aiosmtpd Developers
# SPDX-License-Identifier: Apache-2.0

import asyncio
import os
import ssl
import asyncio
import threading

from aiosmtpd.smtp import SMTP
from contextlib import ExitStack
from public import public
from socket import create_connection
from typing import Any, Coroutine, Dict, Optional
from warnings import warn

from public import public

from aiosmtpd.smtp import SMTP

AsyncServer = asyncio.base_events.Server

Expand Down Expand Up @@ -50,9 +51,11 @@ def __init__(
port=8025,
*,
ready_timeout=1.0,
enable_SMTPUTF8=None,
ssl_context: ssl.SSLContext = None,
server_kwargs: Dict[str, Any] = None
# SMTP parameters
server_hostname: str = None,
Copy link
Collaborator Author

@pepoluan pepoluan Jan 28, 2021

Choose a reason for hiding this comment

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

Need a kwarg that does NOT conflict with Controller's hostname kwarg.

In 2.0 we'll drop hostname from Controller, because the semantically proper name should be host not hostname.

server_kwargs: Dict[str, Any] = None,
**SMTP_parameters,
):
"""
`Documentation can be found here
Expand All @@ -64,23 +67,28 @@ def __init__(
self.port = port
self.ssl_context = ssl_context
self.loop = asyncio.new_event_loop() if loop is None else loop
self.ready_timeout = os.getenv("AIOSMTPD_CONTROLLER_TIMEOUT", ready_timeout)
self.server_kwargs: Dict[str, Any] = server_kwargs or {}
if enable_SMTPUTF8 is not None:
# Uncomment next lines when we hit 1.3
# warn("enable_SMTPUTF8 will be removed in the future. "
# "Please use server_kwargs instead.", DeprecationWarning)
self.server_kwargs["enable_SMTPUTF8"] = enable_SMTPUTF8
else:
# This line emulates previous behavior of defaulting enable_SMTPUTF8 to
# True. Which actually kinda conflicts with SMTP class's default, but it's
# explained in the documentation.
self.server_kwargs.setdefault("enable_SMTPUTF8", True)
self.ready_timeout = os.getenv(
'AIOSMTPD_CONTROLLER_TIMEOUT', ready_timeout)
if server_kwargs:
warn(
"server_kwargs will be removed in version 2.0. "
"Just specify the keyword arguments to forward to SMTP "
"as kwargs to this __init__ method.",
DeprecationWarning
)
self.SMTP_kwargs: Dict[str, Any] = server_kwargs or {}
self.SMTP_kwargs.update(SMTP_parameters)
if server_hostname:
self.SMTP_kwargs["hostname"] = server_hostname
# Emulate previous behavior of defaulting enable_SMTPUTF8 to True
# It actually conflicts with SMTP class's default, but the reasoning is
# discussed in the docs.
self.SMTP_kwargs.setdefault("enable_SMTPUTF8", True)

def factory(self):
"""Allow subclasses to customize the handler/server creation."""
return SMTP(
self.handler, **self.server_kwargs
self.handler, **self.SMTP_kwargs
)

def _factory_invoker(self):
Expand Down Expand Up @@ -112,14 +120,14 @@ def _run(self, ready_event):
srv_coro
)
self.server = srv
except Exception as error: # pragma: nowsl
except Exception as error: # pragma: on-wsl
# Usually will enter this part only if create_server() cannot bind to the
# specified host:port.
#
# Somehow WSL1.0 (Windows Subsystem for Linux) allows multiple
# Somehow WSL 1.0 (Windows Subsystem for Linux) allows multiple
# listeners on one port?!
# That is why we add "pragma: nowsl" there, so when testing on
# WSL we can specify "PLATFORM=wsl".
# That is why we add "pragma: on-wsl" there, so this block will not affect
# coverage on WSL 1.0.
self._thread_exception = error
return
self.loop.call_soon(ready_event.set)
Expand Down Expand Up @@ -149,8 +157,9 @@ def start(self):
self._thread.start()
# Wait a while until the server is responding.
ready_event.wait(self.ready_timeout)
if self._thread_exception is not None: # pragma: nowsl
if self._thread_exception is not None: # pragma: on-wsl
# See comment about WSL1.0 in the _run() method
assert self._thread is not None # Stupid LGTM.com; see github/codeql#4918
raise self._thread_exception
# Apparently create_server invokes factory() "lazily", so exceptions in
# factory() go undetected. To trigger factory() invocation we need to open
Expand All @@ -171,7 +180,7 @@ def _stop(self):
self.loop.stop()
try:
_all_tasks = asyncio.all_tasks
except AttributeError: # pragma: skipif_gt_py36
except AttributeError: # pragma: py-gt-36
_all_tasks = asyncio.Task.all_tasks
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Apparently Python 3.8 raises DeprecationWarning for access to asyncio.Task.all_tasks, messing up the captured warnings inside pytest test cases.

So we invert the attribute access.

for task in _all_tasks(self.loop):
task.cancel()
Expand Down
1 change: 1 addition & 0 deletions aiosmtpd/docs/NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Fixed/Improved
(It gets reimported to ``aiosmtpd.smtp``,
so programs relying on ``aiosmtpd.smtp.__version__`` should still work.)
(Closes #241)
* Uses pure ``pytest`` for all test cases


1.2.4 (2021-01-24)
Expand Down
Loading