test_offline_env_requirements.py 751 B

12345678910111213141516171819202122
  1. import unittest
  2. from scripts.offline_env_requirements import filter_export
  3. class OfflineEnvironmentRequirementsTests(unittest.TestCase):
  4. def test_selects_arm_cpu_and_excludes_windows_cuda(self):
  5. exported = '''
  6. torch==2.14.0+cpu ; platform_machine == "aarch64" and sys_platform == "linux"
  7. torch==2.14.0+cu130 ; sys_platform == "win32"
  8. cuda-toolkit==13.0.3 ; platform_machine != "aarch64" and sys_platform == "linux"
  9. numpy==2.5.3
  10. '''
  11. self.assertEqual(filter_export(exported), 'torch==2.14.0+cpu\nnumpy==2.5.3\n')
  12. def test_rejects_missing_cpu_torch(self):
  13. with self.assertRaisesRegex(RuntimeError, 'target_cpu_torch_missing'):
  14. filter_export('numpy==2.5.3')
  15. if __name__ == '__main__':
  16. unittest.main()