Skip to content

Commit 9bc08d6

Browse files
committed
Fix test and address comments
1 parent e70647c commit 9bc08d6

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

.github/workflows/readme.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ jobs:
2222
run: |
2323
python -m pip install --upgrade pip
2424
python -m pip install invoke rundoc .
25+
python -m pip install tomli
2526
- name: Run the README.md
2627
run: invoke readme

pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ dependencies = [
4242
requires = ['setuptools', 'wheel']
4343
build-backend = "setuptools.build_meta"
4444

45-
# Development dependencies
4645
[project.optional-dependencies]
47-
4846
torch = [
4947
"torch>=1.8.0;python_version<'3.10'",
5048
"torch>=1.11.0;python_version>='3.10' and python_version<'3.11'",
@@ -60,6 +58,7 @@ test = [
6058
'pytest-rerunfailures>=10',
6159
'jupyter>=1.0.0,<2',
6260
'rundoc>=0.4.3,<0.5',
61+
'tomli>=2.0.0,<3',
6362
'invoke',
6463
]
6564

tasks.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import inspect
33
import operator
44
import os
5-
import toml
5+
import tomli
6+
import sys
67
from packaging.requirements import Requirement
78
from packaging.version import Version
89
import shutil
@@ -72,7 +73,7 @@ def _get_minimum_versions(dependencies, python_version):
7273
@task
7374
def install_minimum(c):
7475
with open('pyproject.toml', 'r', encoding='utf-8') as pyproject_file:
75-
pyproject_data = toml.load(pyproject_file)
76+
pyproject_data = tomli.load(pyproject_file)
7677

7778
dependencies = pyproject_data.get('project', {}).get('dependencies', [])
7879
python_version = '.'.join(map(str, sys.version_info[:2]))

tests/test_tasks.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from tasks import _get_minimum_versions
2+
3+
4+
def test_get_minimum_versions():
5+
"""Test the ``_get_minimum_versions`` method.
6+
The method should return the minimum versions of the dependencies for the given python version.
7+
If a library is linked to an URL, the minimum version should be the URL.
8+
"""
9+
# Setup
10+
dependencies = [
11+
"numpy>=1.20.0,<2;python_version<'3.10'",
12+
"numpy>=1.23.3,<2;python_version>='3.10'",
13+
"pandas>=1.2.0,<2;python_version<'3.10'",
14+
"pandas>=1.3.0,<2;python_version>='3.10'",
15+
'humanfriendly>=8.2,<11',
16+
'pandas @ git+https://github.com/pandas-dev/pandas.git@master#egg=pandas'
17+
]
18+
19+
# Run
20+
minimum_versions_39 = _get_minimum_versions(dependencies, '3.9')
21+
minimum_versions_310 = _get_minimum_versions(dependencies, '3.10')
22+
23+
# Assert
24+
expected_versions_39 = [
25+
'numpy==1.20.0',
26+
'pandas @ git+https://github.com/pandas-dev/pandas.git@master#egg=pandas',
27+
'humanfriendly==8.2',
28+
]
29+
expected_versions_310 = [
30+
'numpy==1.23.3',
31+
'pandas @ git+https://github.com/pandas-dev/pandas.git@master#egg=pandas',
32+
'humanfriendly==8.2',
33+
]
34+
35+
assert minimum_versions_39 == expected_versions_39
36+
assert minimum_versions_310 == expected_versions_310

0 commit comments

Comments
 (0)