Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/bin/env python 

2 

3""" 

4camcops_server/tools/run_server_self_tests.py 

5 

6=============================================================================== 

7 

8 Copyright (C) 2012-2020 Rudolf Cardinal (rudolf@pobox.com). 

9 

10 This file is part of CamCOPS. 

11 

12 CamCOPS is free software: you can redistribute it and/or modify 

13 it under the terms of the GNU General Public License as published by 

14 the Free Software Foundation, either version 3 of the License, or 

15 (at your option) any later version. 

16 

17 CamCOPS is distributed in the hope that it will be useful, 

18 but WITHOUT ANY WARRANTY; without even the implied warranty of 

19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

20 GNU General Public License for more details. 

21 

22 You should have received a copy of the GNU General Public License 

23 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>. 

24 

25=============================================================================== 

26 

27**Run server self-tests.** 

28 

29""" 

30 

31import os 

32import subprocess 

33 

34from camcops_server.cc_modules.cc_baseconstants import CAMCOPS_SERVER_DIRECTORY 

35 

36 

37DESCRIPTION = f"""- You can run tests manually via one of these methods: 

38 pytest # all tests 

39 pytest FILE.py # one test file 

40 pytest FILE.py::some_function # one test function 

41 pytest FILE.py::SomeClass # one test class 

42 pytest FILE.py::SomeClass::some_member_function # function within class 

43 pytest -k search_term # all test functions, 

44 # classes etc matching 

45- Pytest will find additional options in: 

46 {CAMCOPS_SERVER_DIRECTORY}/conftest.py 

47 {CAMCOPS_SERVER_DIRECTORY}/pytest.ini 

48- Note that an SQLite database is saved in 

49 {CAMCOPS_SERVER_DIRECTORY} 

50- We'll launch pytest now for the full test suite.""" 

51# https://stackoverflow.com/questions/36456920 

52# examples: 

53# pytest client_api_tests.py::ClientApiTests::test_client_api_validators 

54# pytest webview_tests.py::WebviewTests::test_webview_constant_validators 

55# pytest cc_validator_tests.py 

56 

57 

58def main() -> None: 

59 print(DESCRIPTION) 

60 os.chdir(CAMCOPS_SERVER_DIRECTORY) 

61 subprocess.run("pytest", shell=True) 

62 

63 

64if __name__ == "__main__": 

65 main()