Пример #1
0
 def test_validate_path(self):
     install_dir = os.path.expanduser(os.path.join('~', '.cmdstanpy'))
     install_version = os.path.expanduser(
         os.path.join(install_dir, get_latest_cmdstan(install_dir)))
     set_cmdstan_path(install_version)
     validate_cmdstan_path(install_version)
     path_foo = os.path.abspath(os.path.join('releases', 'foo'))
     with self.assertRaisesRegex(ValueError, 'no such CmdStan directory'):
         validate_cmdstan_path(path_foo)
     path_test = os.path.abspath('test')
     with self.assertRaisesRegex(ValueError, 'no CmdStan binaries'):
         validate_cmdstan_path(path_test)
Пример #2
0
 def test_validate_path(self):
     install_dir = os.path.expanduser(os.path.join('~', '.cmdstanpy'))
     install_version = os.path.expanduser(
         os.path.join(install_dir, get_latest_cmdstan(install_dir)))
     set_cmdstan_path(install_version)
     validate_cmdstan_path(install_version)
     path_foo = os.path.abspath(os.path.join('releases', 'foo'))
     with self.assertRaisesRegex(ValueError, 'no such CmdStan directory'):
         validate_cmdstan_path(path_foo)
     folder_name = ''.join(
         random.choice(string.ascii_letters) for _ in range(10))
     while os.path.exists(folder_name):
         folder_name = ''.join(
             random.choice(string.ascii_letters) for _ in range(10))
     os.makedirs(folder_name)
     path_test = os.path.abspath(folder_name)
     with self.assertRaisesRegex(ValueError, 'no CmdStan binaries'):
         validate_cmdstan_path(path_test)
     shutil.rmtree(folder_name)
Пример #3
0
    def test_validate_path(self):
        if 'CMDSTAN' in os.environ:
            install_version = os.environ.get('CMDSTAN')
        else:
            cmdstan_dir = os.path.expanduser(os.path.join('~', _DOT_CMDSTAN))

            install_version = os.path.join(cmdstan_dir,
                                           get_latest_cmdstan(cmdstan_dir))

        set_cmdstan_path(install_version)
        validate_cmdstan_path(install_version)
        path_foo = os.path.abspath(os.path.join('releases', 'foo'))
        with self.assertRaisesRegex(ValueError, 'No CmdStan directory'):
            validate_cmdstan_path(path_foo)
        folder_name = ''.join(
            random.choice(string.ascii_letters) for _ in range(10))
        while os.path.exists(folder_name):
            folder_name = ''.join(
                random.choice(string.ascii_letters) for _ in range(10))
        os.makedirs(folder_name)
        path_test = os.path.abspath(folder_name)
        with self.assertRaisesRegex(ValueError, 'missing binaries'):
            validate_cmdstan_path(path_test)
        shutil.rmtree(folder_name)