1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
import unittest
from cpuinfo import *
import helpers
class MockDataSource:
bits = '64bit'
cpu_count = 1
is_windows = False
arch_string_raw = 'x86_64'
uname_string_raw = 'x86_64'
@staticmethod
def has_proc_cpuinfo():
return False
@staticmethod
def has_dmesg():
return False
@staticmethod
def has_var_run_dmesg_boot():
return False
@staticmethod
def has_cpufreq_info():
return False
@staticmethod
def has_sestatus():
return False
@staticmethod
def has_sysctl():
return False
@staticmethod
def has_isainfo():
return False
@staticmethod
def has_kstat():
return False
@staticmethod
def has_sysinfo():
return False
@staticmethod
def has_lscpu():
return False
@staticmethod
def cat_proc_cpuinfo():
return 1, None
@staticmethod
def cpufreq_info():
return 1, None
@staticmethod
def sestatus_b():
return 1, None
@staticmethod
def dmesg_a():
return 1, None
@staticmethod
def cat_var_run_dmesg_boot():
return 1, None
@staticmethod
def sysctl_machdep_cpu_hw_cpufrequency():
return 1, None
@staticmethod
def isainfo_vb():
return 1, None
@staticmethod
def kstat_m_cpu_info():
return 1, None
@staticmethod
def lscpu():
return 1, None
@staticmethod
def sysinfo_cpu():
return 1, None
@staticmethod
def winreg_processor_brand():
return None
@staticmethod
def winreg_vendor_id_raw():
return None
@staticmethod
def winreg_arch_string_raw():
return None
@staticmethod
def winreg_hz_actual():
return None
@staticmethod
def winreg_feature_bits():
return None
class TestExample(unittest.TestCase):
def setUp(self):
helpers.backup_data_source(cpuinfo)
helpers.monkey_patch_data_source(cpuinfo, MockDataSource)
def tearDown(self):
helpers.restore_data_source(cpuinfo)
def test_all(self):
self.assertEqual({}, cpuinfo._get_cpu_info_from_registry())
self.assertEqual({}, cpuinfo._get_cpu_info_from_proc_cpuinfo())
self.assertEqual({}, cpuinfo._get_cpu_info_from_sysctl())
self.assertEqual({}, cpuinfo._get_cpu_info_from_kstat())
self.assertEqual({}, cpuinfo._get_cpu_info_from_dmesg())
self.assertEqual({}, cpuinfo._get_cpu_info_from_cat_var_run_dmesg_boot())
self.assertEqual({}, cpuinfo._get_cpu_info_from_sysinfo())
#self.assertEqual({}, cpuinfo._get_cpu_info_from_cpuid())
#self.assertEqual({}, cpuinfo._get_cpu_info_internal())
|