Best Python code snippet using autotest_python
systemtools.py
Source:systemtools.py
...262 st.run_cmd = mocked_run_cmd263 self.assertEqual(get_cpu_vendor(), INTEL)264 def test_cpu_family_native(self):265 """Test get_cpu_family function."""266 cpu_family = get_cpu_family()267 self.assertTrue(cpu_family in CPU_FAMILIES or cpu_family == UNKNOWN)268 def test_cpu_family_linux(self):269 """Test get_cpu_family function (mocked for Linux)."""270 st.get_os_type = lambda: st.LINUX271 st.read_file = mocked_read_file272 st.os.path.exists = lambda fp: mocked_os_path_exists(PROC_CPUINFO_FP, fp)273 global PROC_CPUINFO_TXT274 PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_X86275 self.assertEqual(get_cpu_family(), INTEL)276 PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_ARM277 self.assertEqual(get_cpu_family(), ARM)278 PROC_CPUINFO_TXT = PROC_CPUINFO_TXT_POWER279 self.assertEqual(get_cpu_family(), POWER)280 def test_cpu_family_darwin(self):281 """Test get_cpu_family function (mocked for Darwin)."""282 st.get_os_type = lambda: st.DARWIN283 st.run_cmd = mocked_run_cmd284 self.assertEqual(get_cpu_family(), INTEL)285 def test_os_type(self):286 """Test getting OS type."""287 os_type = get_os_type()288 self.assertTrue(os_type in [DARWIN, LINUX])289 def test_shared_lib_ext_native(self):290 """Test getting extension for shared libraries."""291 ext = get_shared_lib_ext()292 self.assertTrue(ext in ['dylib', 'so'])293 def test_shared_lib_ext_native(self):294 """Test getting extension for shared libraries (mocked for Linux)."""295 st.get_os_type = lambda: st.LINUX296 self.assertEqual(get_shared_lib_ext(), 'so')297 def test_shared_lib_ext_native(self):298 """Test getting extension for shared libraries (mocked for Darwin)."""...
get_information.py
Source:get_information.py
...33 key = winreg.OpenKey(reg, r"HARDWARE\DESCRIPTION\System\CentralProcessor\0")34 return winreg.QueryValueEx(key, 'ProcessorNameString')[0].strip()353637def get_cpu_family() -> str:38 return platform.processor()394041def get_gpu() -> str:42 reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)43 key = winreg.OpenKey(reg, r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinSAT")44 return winreg.QueryValueEx(key, 'PrimaryAdapterString')[0].strip()454647def get_names_disks() -> list:48 serials = subprocess.check_output('wmic diskdrive get SerialNumber').decode().split('\n')[1:]49 return [s.strip() for s in serials if not s.strip().isdigit() and s.strip()]505152def get_windows_version() -> int:53 return int(platform.release())545556def get_monitor_size() -> list:57 user32 = ctypes.windll.user3258 user32.SetProcessDPIAware()59 return [user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)]606162user = get_user()63user_domain = get_user_domain()64cpu = get_cpu_name()65cpu_family = get_cpu_family()66gpu = get_gpu()67names_disks = get_names_disks()68windows_version = get_windows_version()69monitor_size = get_monitor_size()7071print(f"user: {user}")72print(f"user domain: {user_domain}")73print(f"cpu: {cpu}")74print(f"cpu family: {cpu_family}")75print(f"gpu: {gpu}")76print(f"names disks: {names_disks}")77print(f"windows version: {windows_version}")
...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!