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

Give test subclasses unique names to avoid race conditions #3

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.5, 3.6, 3.7]
python-version: [3.5, 3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v1
Expand All @@ -33,3 +33,4 @@ jobs:
run: ci/actions/test
env:
RUST_BACKTRACE: 1
PYTHONUNBUFFERED: 1
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ matrix:
- name: PyPy3.5 7.0 # Tested via anaconda PyPy (since travis's PyPy version is too old)
python: "3.7"
env: FEATURES="pypy" PATH="$PATH:/opt/anaconda/envs/pypy3/bin"
allow_failures:
- python: "3.8-dev"

env:
global:
Expand Down
18 changes: 14 additions & 4 deletions tests/test_datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,31 @@ fn _get_subclasses<'p>(

let locals = [(py_type, datetime.get(py_type)?)].into_py_dict(*py);

let make_subclass_py = format!("class Subklass({}):\n pass", py_type);
let subclass_name = format!("Subklass{}", py_type);
let make_subclass_py = format!("class {}({}):\n pass", subclass_name, py_type);

let make_sub_subclass_py = "class SubSubklass(Subklass):\n pass";
let subsubclass_name = format!("SubSubklass{}", py_type);
let make_sub_subclass_py = format!("class {}({}):\n pass", subsubclass_name, subclass_name);

py.run(&make_subclass_py, None, Some(&locals))?;
py.run("print('subclass ok')", None, None)?;
py.run(&make_sub_subclass_py, None, Some(&locals))?;
py.run("print('subsubclass ok')", None, None)?;

// Construct an instance of the base class
let obj = py.eval(&format!("{}({})", py_type, args), None, Some(&locals))?;

// Construct an instance of the subclass
let sub_obj = py.eval(&format!("Subklass({})", args), None, Some(&locals))?;
let sub_obj = py.eval(&format!("{}({})", subclass_name, args), None, Some(&locals))?;
py.run("print('instance subclass ok')", None, None)?;

// Construct an instance of the sub-subclass
let sub_sub_obj = py.eval(&format!("SubSubklass({})", args), None, Some(&locals))?;
let sub_sub_obj = py.eval(
&format!("{}({})", subsubclass_name, args),
None,
Some(&locals),
)?;
py.run("print('instance subsubclass ok')", None, None)?;

Ok((obj, sub_obj, sub_sub_obj))
}
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
envlist = py35,
py36,
py37,
py38,
minversion = 3.4.0
skip_missing_interpreters = true

Expand Down