def read_resource(path, file_open_mode='r'): if not pip and path in rs.iterkeys( prefix='resfs/file/load/projects/yandex-tank/'): return rs.find(path) else: with open(path, file_open_mode) as f: return f.read()
def iter_binaries(): ok = False for l in lpr.find('/test_binaries').split('\n'): if '# start' in l: ok = True else: if '# end' in l: ok = False if ok: yield construct_path(l.strip())
def test_export_model_with_cat_features_to_python_from_app(): test_pool = Pool(TEST_FILE, column_description=CD_FILE) model = CatBoost() with open(OUTPUT_MODEL_PATH, "w") as model_file: model_file.write(resource.find("cb_adult_model_bin")) model.load_model(OUTPUT_MODEL_PATH) pred_model = model.predict(test_pool, prediction_type='RawFormulaVal') from adult_model import apply_catboost_model as apply_catboost_model_from_app pred_python = [] for test_line in test_pool.get_features(): float_features, cat_features = _split_features( test_line, test_pool.get_cat_feature_indices(), test_pool.get_cat_feature_hash_to_string()) pred_python.append( apply_catboost_model_from_app(float_features, cat_features)) assert _check_data(pred_model, pred_python)
def getzoneinfofile_stream(): try: return BytesIO(resource.find('zoneinfo/dateutil-zoneinfo.tar.gz')) except IOError as e: # TODO switch to FileNotFoundError? warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror)) return None
def test_simple(): assert rs.find('/qw.txt') == text
def ctx(self): r = resource.find("/builtin/cacert") # ssl.create_default_context expects unicode string for pem-coded certificates r = r.decode('ascii', errors='ignore') return ssl.create_default_context(cadata=r)
def test_find(): assert rs.find('/qw.txt') == text
def test_simple(): assert (rs.find(b'/qw.txt') == text)