Skip to content

Commit

Permalink
Configure Nox to run snippets on supported Python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
nifadyev committed Oct 17, 2024
1 parent 817ba3e commit 57c94dc
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
13 changes: 13 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from typing import TYPE_CHECKING

import nox


if TYPE_CHECKING:
from nox.sessions import Session

python_versions = ["3.9", "3.10", "3.11", "3.12", "3.13"]

@nox.session(python=python_versions, reuse_venv=True)
def tests(session: "Session") -> None:
_ = session.run("python", "snippets/2_tricky_strings.py")
31 changes: 31 additions & 0 deletions snippets/2_tricky_strings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 1
assert id("some_string") == id("some" + "_" + "string")
assert id("some_string") == id("some_string")

# 2
a = "wtf"
b = "wtf"
assert a is b

a = "wtf!"
b = "wtf!"
# True because it is invoked in script. Might be False in python shell or ipython
assert a is b

# 3
a, b = "wtf!", "wtf!"
assert a is b

a = "wtf!"; b = "wtf!" # noqa: E702 - multiline statement
# True because it is invoked in script. Might be False in python shell or ipython
assert a is b

# 4 - not relevant for modern (>3.8) Python version, should be moved to `legacy` section
# a = 'a' * 20
# b = 'aaaaaaaaaaaaaaaaaaaa'
# assert a is b
#
# a = 'a' * 21
# b = 'aaaaaaaaaaaaaaaaaaaa'
# # Fails
# assert a is b
Empty file added snippets/__init__.py
Empty file.

0 comments on commit 57c94dc

Please sign in to comment.