def test_all_options_valid(self):
     test_config = """
     [default]
     circuit_drawer = latex
     circuit_mpl_style = default
     circuit_mpl_style_path = ~:~/.qiskit
     transpile_optimization_level = 3
     suppress_packaging_warnings = true
     parallel = false
     num_processes = 15
     """
     self.addCleanup(os.remove, self.file_path)
     with open(self.file_path, 'w') as file:
         file.write(test_config)
         file.flush()
         config = user_config.UserConfig(self.file_path)
         config.read_config_file()
         self.assertEqual({'circuit_drawer': 'latex',
                           'circuit_mpl_style': 'default',
                           'circuit_mpl_style_path': ['~', '~/.qiskit'],
                           'transpile_optimization_level': 3,
                           'num_processes': 15,
                           'parallel_enabled': False,
                           'suppress_packaging_warnings': True},
                          config.settings)
Esempio n. 2
0
    def test_all_options_valid(self):
        test_config = """
        [default]
        circuit_drawer = latex
        circuit_mpl_style = default
        circuit_mpl_style_path = ~:~/.qiskit
        transpile_optimization_level = 3
        suppress_packaging_warnings = true
        parallel = false
        num_processes = 15
        """
        self.addCleanup(os.remove, self.file_path)
        with open(self.file_path, "w") as file:
            file.write(test_config)
            file.flush()
            config = user_config.UserConfig(self.file_path)
            config.read_config_file()

        self.assertEqual(
            {
                "circuit_drawer": "latex",
                "circuit_mpl_style": "default",
                "circuit_mpl_style_path": ["~", "~/.qiskit"],
                "transpile_optimization_level": 3,
                "num_processes": 15,
                "parallel_enabled": False,
            },
            config.settings,
        )
 def test_invalid_suppress_packaging_warnings(self):
     test_config = """
     [default]
     suppress_packaging_warnings = 76
     """
     self.addCleanup(os.remove, self.file_path)
     with open(self.file_path, 'w') as file:
         file.write(test_config)
         file.flush()
         config = user_config.UserConfig(self.file_path)
         self.assertRaises(ValueError, config.read_config_file)
Esempio n. 4
0
 def test_circuit_drawer_valid(self):
     test_config = """
     [default]
     circuit_drawer = latex
     """
     file_path = tempfile.NamedTemporaryFile(mode='w')
     self.addCleanup(file_path.close)
     file_path.write(test_config)
     file_path.flush()
     config = user_config.UserConfig(file_path.name)
     config.read_config_file()
     self.assertEqual({'circuit_drawer': 'latex'}, config.settings)
 def test_optimization_level_valid(self):
     test_config = """
     [default]
     transpile_optimization_level = 1
     """
     file_path = tempfile.NamedTemporaryFile(mode='w')
     self.addCleanup(file_path.close)
     file_path.write(test_config)
     file_path.flush()
     config = user_config.UserConfig(file_path.name)
     config.read_config_file()
     self.assertEqual({'transpile_optimization_level': 1}, config.settings)
 def test_invalid_optimization_level(self):
     test_config = """
     [default]
     transpile_optimization_level = 76
     """
     file_path = tempfile.NamedTemporaryFile(mode='w')
     self.addCleanup(file_path.close)
     file_path.write(test_config)
     file_path.flush()
     config = user_config.UserConfig(file_path.name)
     self.assertRaises(exceptions.QiskitUserConfigError,
                       config.read_config_file)
 def test_valid_num_processes(self):
     test_config = """
     [default]
     num_processes = 31
     """
     self.addCleanup(os.remove, self.file_path)
     with open(self.file_path, 'w') as file:
         file.write(test_config)
         file.flush()
         config = user_config.UserConfig(self.file_path)
         config.read_config_file()
         self.assertEqual({'num_processes': 31}, config.settings)
 def test_circuit_drawer_valid(self):
     test_config = """
     [default]
     circuit_drawer = latex
     """
     self.addCleanup(os.remove, self.file_path)
     with open(self.file_path, 'w') as file:
         file.write(test_config)
         file.flush()
         config = user_config.UserConfig(self.file_path)
         config.read_config_file()
         self.assertEqual({'circuit_drawer': 'latex'}, config.settings)
 def test_valid_parallel(self):
     test_config = """
     [default]
     parallel = False
     """
     self.addCleanup(os.remove, self.file_path)
     with open(self.file_path, 'w') as file:
         file.write(test_config)
         file.flush()
         config = user_config.UserConfig(self.file_path)
         config.read_config_file()
         self.assertEqual({'parallel_enabled': False}, config.settings)
Esempio n. 10
0
 def test_valid_suppress_packaging_warnings_false(self):
     test_config = """
     [default]
     suppress_packaging_warnings = false
     """
     self.addCleanup(os.remove, self.file_path)
     with open(self.file_path, 'w') as file:
         file.write(test_config)
         file.flush()
         config = user_config.UserConfig(self.file_path)
         config.read_config_file()
         self.assertEqual({}, config.settings)
 def test_invalid_circuit_drawer(self):
     test_config = """
     [default]
     circuit_drawer = MSPaint
     """
     self.addCleanup(os.remove, self.file_path)
     with open(self.file_path, 'w') as file:
         file.write(test_config)
         file.flush()
         config = user_config.UserConfig(self.file_path)
         self.assertRaises(exceptions.QiskitUserConfigError,
                           config.read_config_file)
Esempio n. 12
0
 def test_invalid_circuit_drawer(self):
     test_config = """
     [default]
     circuit_drawer = MSPaint
     """
     file_path = tempfile.NamedTemporaryFile(mode='w')
     self.addCleanup(file_path.close)
     file_path.write(test_config)
     file_path.flush()
     config = user_config.UserConfig(file_path.name)
     self.assertRaises(exceptions.QiskitUserConfigError,
                       config.read_config_file)
 def test_invalid_num_processes(self):
     test_config = """
     [default]
     num_processes = -256
     """
     self.addCleanup(os.remove, self.file_path)
     with open(self.file_path, 'w') as file:
         file.write(test_config)
         file.flush()
         config = user_config.UserConfig(self.file_path)
         self.assertRaises(exceptions.QiskitUserConfigError,
                           config.read_config_file)
 def test_invalid_optimization_level(self):
     test_config = """
     [default]
     transpile_optimization_level = 76
     """
     self.addCleanup(os.remove, self.file_path)
     with open(self.file_path, 'w') as file:
         file.write(test_config)
         file.flush()
         config = user_config.UserConfig(self.file_path)
         self.assertRaises(exceptions.QiskitUserConfigError,
                           config.read_config_file)
Esempio n. 15
0
 def test_optimization_level_valid(self):
     test_config = """
     [default]
     transpile_optimization_level = 1
     """
     self.addCleanup(os.remove, self.file_path)
     with open(self.file_path, 'w') as file:
         file.write(test_config)
         file.flush()
         config = user_config.UserConfig(self.file_path)
         config.read_config_file()
         self.assertEqual({'transpile_optimization_level': 1},
                          config.settings)
 def test_valid_suppress_packaging_warnings_true(self):
     test_config = """
     [default]
     suppress_packaging_warnings = true
     """
     self.addCleanup(os.remove, self.file_path)
     with open(self.file_path, 'w') as file:
         file.write(test_config)
         file.flush()
         config = user_config.UserConfig(self.file_path)
         config.read_config_file()
         self.assertEqual(
             {'parallel_enabled': user_config.PARALLEL_DEFAULT,
              'suppress_packaging_warnings': True},
             config.settings)
Esempio n. 17
0
 def test_all_options_valid(self):
     test_config = """
     [default]
     circuit_drawer = latex
     circuit_mpl_style = default
     transpile_optimization_level = 3
     """
     self.addCleanup(os.remove, self.file_path)
     with open(self.file_path, 'w') as file:
         file.write(test_config)
         file.flush()
         config = user_config.UserConfig(self.file_path)
         config.read_config_file()
         self.assertEqual(
             {
                 'circuit_drawer': 'latex',
                 'circuit_mpl_style': 'default',
                 'transpile_optimization_level': 3
             }, config.settings)
 def test_all_options_valid(self):
     test_config = """
     [default]
     circuit_drawer = latex
     circuit_mpl_style = default
     transpile_optimization_level = 3
     """
     file_path = tempfile.NamedTemporaryFile(mode='w')
     self.addCleanup(file_path.close)
     file_path.write(test_config)
     file_path.flush()
     config = user_config.UserConfig(file_path.name)
     config.read_config_file()
     self.assertEqual(
         {
             'circuit_drawer': 'latex',
             'circuit_mpl_style': 'default',
             'transpile_optimization_level': 3
         }, config.settings)
Esempio n. 19
0
 def test_empty_file_read(self):
     file_path = tempfile.NamedTemporaryFile()
     self.addCleanup(file_path.close)
     config = user_config.UserConfig(file_path.name)
     config.read_config_file()
     self.assertEqual({}, config.settings)
 def test_empty_file_read(self):
     config = user_config.UserConfig(self.file_path)
     config.read_config_file()
     self.assertEqual({},
                      config.settings)