Files
ortools-clone/ortools/init/python/pywrapinit_test.py

55 lines
2.0 KiB
Python
Raw Normal View History

2022-10-14 17:14:17 +02:00
#!/usr/bin/env python3
2022-06-17 08:40:20 +02:00
# Copyright 2010-2022 Google LLC
2021-11-26 17:36:09 +01:00
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2022-09-26 17:38:42 +02:00
"""Simple unit tests for python/init.i. Not exhaustive."""
2021-11-26 17:36:09 +01:00
import unittest
from ortools.init import pywrapinit
2022-09-27 18:00:48 +02:00
2021-11-26 17:36:09 +01:00
class PyWrapInit(unittest.TestCase):
2021-11-30 22:37:45 +01:00
def test_logging(self):
print('test_logging')
2021-11-26 17:36:09 +01:00
pywrapinit.CppBridge.InitLogging('pywrapinit_test.py')
pywrapinit.CppBridge.ShutdownLogging()
def test_flags(self):
2021-11-30 22:37:45 +01:00
print('test_cpp_flags')
2021-11-26 17:36:09 +01:00
cpp_flags = pywrapinit.CppFlags()
2022-09-27 18:00:48 +02:00
# print(f'{dir(cpp_flags)}')
2023-02-17 13:13:13 +01:00
assert hasattr(cpp_flags, 'stderrthreshold')
2022-09-27 18:00:48 +02:00
assert hasattr(cpp_flags, 'log_prefix')
assert hasattr(cpp_flags, 'cp_model_dump_prefix')
assert hasattr(cpp_flags, 'cp_model_dump_models')
assert hasattr(cpp_flags, 'cp_model_dump_lns')
assert hasattr(cpp_flags, 'cp_model_dump_response')
2021-11-26 17:36:09 +01:00
pywrapinit.CppBridge.SetFlags(cpp_flags)
def test_version(self):
print('test_version')
2021-11-30 22:37:45 +01:00
major = pywrapinit.OrToolsVersion.MajorNumber()
self.assertIsInstance(major, int)
minor = pywrapinit.OrToolsVersion.MinorNumber()
self.assertIsInstance(minor, int)
patch = pywrapinit.OrToolsVersion.PatchNumber()
self.assertIsInstance(patch, int)
version = pywrapinit.OrToolsVersion.VersionString()
self.assertIsInstance(version, str)
2021-11-26 17:36:09 +01:00
string = f'{major}.{minor}.{patch}'
2021-11-30 22:37:45 +01:00
self.assertEqual(version, string)
2021-11-26 17:36:09 +01:00
2022-09-27 18:00:48 +02:00
2021-11-26 17:36:09 +01:00
if __name__ == '__main__':
unittest.main()