Skip to content

Commit d334756

Browse files
committed
Fix tests
1 parent 4c8a6dc commit d334756

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
6969
- name: Run Tests
7070
run: |
71-
pytest tests -m "not server_api"
71+
pytest tests -m "not server_api and not slow"
7272
7373
build-release:
7474
name: Build and Upload Release

cadetrdm/environment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ def prepare_install_instructions(self):
215215
if "git+" in spec:
216216
raise ValueError(f"Conda can not use git+ dependencies for {package} {spec}")
217217
elif "~" in spec:
218-
conda_command += f" '{package}={spec.replace('~', '').replace('=', '')}'"
218+
conda_command += f" {package}={spec.replace('~', '').replace('=', '')}"
219219
elif ">" in spec or "<" in spec or "=" in spec:
220-
conda_command += f" '{package}{spec}'"
220+
conda_command += f" {package}{spec}"
221221
else:
222-
conda_command += f" '{package}={spec}'"
222+
conda_command += f" {package}={spec}"
223223

224224
if self.pip_packages is not None:
225225
pip_command = "pip install"

tests/test_logging.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,36 +117,35 @@ def test_environment():
117117
pip_packages={"xarray": ">2024.2.0", "pydantic": "<=2.6.4", }
118118
)
119119

120-
install_instructions = ('conda install -y cadet=4.4.0 tbb=2024.0.0', 'pip install xarray==2024.2.0')
120+
install_instructions = ("conda install -y cadet=4.4.0 tbb=2024.0.0", "pip install 'xarray==2024.2.0'")
121121
assert environment.prepare_install_instructions() == install_instructions
122122

123123

124124
@pytest.mark.slow
125125
def test_update_environment():
126126
subprocess.run(f'conda env remove -n testing_env_cadet_rdm -y', shell=True)
127-
subprocess.run(f'conda create -n testing_env_cadet_rdm python=3.12 -y', shell=True)
127+
subprocess.run(f'conda create -n testing_env_cadet_rdm python=3.11 -y', shell=True)
128128
target_env = Environment(
129129
conda_packages={"libiconv": "1.17", "openssl": ">=3.3"},
130-
pip_packages={"cadet-rdm": "0.0.44"}
130+
# pip_packages={"cadet-rdm": "0.0.44"}
131131
)
132-
current_env = Environment.from_yml_string(subprocess.check_output(
133-
"conda activate testing_env_cadet_rdm & conda env export",
134-
shell=True
135-
).decode())
132+
133+
check = subprocess.run("conda env export -n testing_env_cadet_rdm ", shell=True, capture_output=True)
134+
current_env = Environment.from_yml_string(check.stdout.decode())
136135
assert not current_env.fulfils_environment(target_env)
137136

138137
conda_instructions, pip_instructions = target_env.prepare_install_instructions()
139-
conda_instructions = "conda activate testing_env_cadet_rdm && " + conda_instructions
140-
pip_instructions = "conda activate testing_env_cadet_rdm && " + pip_instructions
138+
conda_instructions = conda_instructions.replace("install -y", "install --name testing_env_cadet_rdm -y")
141139
print(conda_instructions)
142-
print(pip_instructions)
143140
subprocess.run(conda_instructions, shell=True)
144-
subprocess.run(pip_instructions, shell=True)
145141

146-
current_env = Environment.from_yml_string(subprocess.check_output(
147-
f"conda activate testing_env_cadet_rdm && conda env export",
148-
shell=True
149-
).decode())
142+
# Currently not aware of any way of activating a conda env and then running commands in it.
143+
# pip_instructions = "conda run -n testing_env_cadet_rdm " + pip_instructions
144+
# print(pip_instructions)
145+
# subprocess.run(pip_instructions, shell=True)
146+
147+
check = subprocess.run("conda env export -n testing_env_cadet_rdm ", shell=True, capture_output=True)
148+
current_env = Environment.from_yml_string(check.stdout.decode())
150149
assert current_env.fulfils_environment(target_env)
151150

152151

0 commit comments

Comments
 (0)