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

TST: Properly test with pymongo, adjust profiler usage for py3.12 #346

Merged
merged 4 commits into from
Aug 27, 2024
Merged
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
2 changes: 2 additions & 0 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ test:
- pytest
- ipython
- line_profiler
- mongomock
- pcdsutils
- pcdsdevices
- pymongo

about:
dev_url: https://github.com/pcdshub/happi/
Expand Down
1 change: 1 addition & 0 deletions happi/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def test_beckoff_axis_device_class(mockqsbackend):
assert sam_x.__class__.__name__ == 'IMS'


@requires_mongo
def test_multi_backend(mockmulti, item_info, valve_info):
mm = mockmulti
assert len(mm.all_items) == 3
Expand Down
13 changes: 4 additions & 9 deletions happi/tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# test_cli.py

import cProfile
import functools
import itertools
import logging
import pstats
import re
from collections.abc import Iterable
from typing import Any
Expand Down Expand Up @@ -829,14 +827,11 @@ def test_profile_cli(runner: CliRunner, happi_cfg: str, args: tuple[str]):
print("Resetting the line profiler...")
pcdsutils.profile.reset_profiler()

with cProfile.Profile() as pr:
result = runner.invoke(
happi_cli,
['--path', happi_cfg, 'profile'] + list(args),
)
result = runner.invoke(
happi_cli,
['--path', happi_cfg, 'profile'] + list(args),
)

st = pstats.Stats(pr).strip_dirs().sort_stats("tottime")
st.print_stats(20)
assert_in_expected(
result,
'Profile completed successfully'
Expand Down