From fdc596d1d5a7c36c440f32e45618b66fe80cdb41 Mon Sep 17 00:00:00 2001 From: kasinadhsarma Date: Thu, 26 Dec 2024 13:30:37 +0530 Subject: [PATCH] Add environment variable checks to test suite and include numpy as a required package --- ...t_environment.cpython-310-pytest-8.3.4.pyc | Bin 9452 -> 9898 bytes tests/test_environment.py | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/__pycache__/test_environment.cpython-310-pytest-8.3.4.pyc b/tests/__pycache__/test_environment.cpython-310-pytest-8.3.4.pyc index 109ddada61d6b735089008e1d8b2412bd405f02f..50c3dc702185fd94e23256316853ee4a41190d81 100644 GIT binary patch delta 2243 zcmaJ?U2Gdg5WYR%*%#Mw6Wd9g#7UgLCRR#XCxt>A6{}FL+GuFAGRxAYM)NT#*22Fg`jaX!*$1z+1;8MN46n;j-d7f+gk-3OJ0*ie7Nli) zMIx{}%+&a4x!+rM#|MYvgWF>Ye?yM$cGO%kTbOs0gNF}|I?4-sj~^V5xtw}N=ZYqy zMxvl6XY~}d9#YX-Le#r0Y5%e*U{MOX|6< zwujJ=2?(N82hd*O>KGv%{H}Wo*}@f1Z_lGvPSB>7ohZ!PGx=PiM44sgbMeX{&o2sT zsqFE^adM%yc?ZUV^#M4(qs5$UX6YzndB%ECrRkPMnLU;Q1rcNh#N*NOsM9ivJLtaP`i0^5;U&2hbgc5R-qr;{o{E3S~%Dl&|TnvgbuctAe95hX7mD$W=$)r+sT<|J{M(E{8Ym>(!wt_^o&p8 z60-5sWV+y*M2C4nKp*@<$>565RA@^vz z9+)aiKGN9gKMy0~CTX%J4_0X7T>^~uh2ynbaV?qQAKS`b3-5JLp*YKLhuhs%lKg(S zm9A}EJ%1|Gb4CtMlWu2=88(k|$_S70T}>?0a7d)imDCG@s6*!e%Qe&7N#3cv-TWod z&cc+BWtQeIwT=ynB)kQh7;!vjGI`w|9%3RNBKwc#;}*ZuIYytM-<5S`;ySQ?{!e?XPB^#bp%dYY9TD*m%)61>}sN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wr>N=@F$aUvz=WnMJvI-NhZkW)pwJB5GPA46{CEw^XfC$Oh?tQr7Piv-9mWX4svEW z`1{X!woFIZI|uXibcWpGd+7xji9xPs9@=QeI5^qZ5W*z{H-a6dR#di(Hf%ul0>aA( z*AZStu)`mKJucz$31~7p03^XpM6sTTb@fCFNK$ha-W^iVE450oMu|U=J(cVQKj@4) z7@9L>Lo-+9xFyY0w4$l$1{>pB*&**J_^>#?mF*-k{!4a%$GekfUqd6-$C56<@EucN ucH-&w@U+||MbrO_p(Twt1N1ZjXCuR}bcX|eAQ=#a4JlVoLZq3v_x}c*FNO*L diff --git a/tests/test_environment.py b/tests/test_environment.py index 2036aa4..eb94584 100644 --- a/tests/test_environment.py +++ b/tests/test_environment.py @@ -7,6 +7,7 @@ from unittest import skipIf from packaging import version # Fix: import version directly import torch +import os # Added for environment variable checks logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) @@ -20,8 +21,10 @@ def setUpClass(cls): cls.required_packages = { 'torch': '2.0.1', 'torchvision': '0.15.2', - 'torchaudio': '2.0.1' + 'torchaudio': '2.0.1', + 'numpy': '1.21.0' # Added numpy as an example } + cls.required_env_vars = ['HOME', 'PATH'] # Example environment variables cls._check_package_installations() @classmethod @@ -124,7 +127,7 @@ def test_memory_allocation(self): import torch test_sizes = [(1000, 1000), (2000, 2000)] - devices = ['cpu'] + [f'cuda:{i}' for i in range(torch.cuda.device_count())] if torch.cuda.is_available() else [] + devices = ['cpu'] + [f'cuda:{i}' for i in range(torch.cuda.device_count())] if torch.cuda.is_available() else ['cpu'] for device in devices: for size in test_sizes: @@ -216,6 +219,13 @@ def test_error_handling_and_logging(self): logger.error(f"Unexpected error during tensor creation: {str(e)}") self.fail(f"Unexpected error during tensor creation: {str(e)}") + def test_environment_variables(self): + """Verify essential environment variables are set""" + for var in self.required_env_vars: + value = os.getenv(var) + self.assertIsNotNone(value, f"Environment variable '{var}' is not set") + logger.info(f"Environment variable '{var}': {value}") + if __name__ == '__main__': logger.info("Starting environment tests") logger.info(f"Platform: {platform.platform()}")