aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanila-eremin <danila-eremin@yandex-team.ru>2022-02-10 16:46:21 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:21 +0300
commit9d80afb43be16931e653a688c5e0f585101ff4f8 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c
parent358e631d1a69242d3ae4d6e6b1e4f7581d03133b (diff)
downloadydb-9d80afb43be16931e653a688c5e0f585101ff4f8.tar.gz
Restoring authorship annotation for <danila-eremin@yandex-team.ru>. Commit 2 of 2.
-rw-r--r--contrib/python/pytest/py2/_pytest/python.py2
-rw-r--r--contrib/python/pytest/py2/patches/08-backport-pr-6607.patch30
-rw-r--r--contrib/python/ya.make2
-rw-r--r--contrib/restricted/boost/boost/multiprecision/cpp_int.hpp48
-rw-r--r--contrib/restricted/boost/boost/regex/v4/regex_token_iterator.hpp4
-rw-r--r--contrib/tools/bison/bison/data/lalr1.cc18
-rw-r--r--library/cpp/digest/md5/bench/main.cpp12
-rw-r--r--library/cpp/digest/md5/bench/ya.make2
-rw-r--r--library/cpp/digest/md5/md5.cpp190
-rw-r--r--library/cpp/digest/md5/md5.h46
-rw-r--r--library/cpp/digest/md5/md5_ut.cpp8
-rw-r--r--library/cpp/tvmauth/client/ut/settings_ut.cpp4
-rw-r--r--library/python/pytest/plugins/collection.py72
-rw-r--r--library/python/pytest/plugins/ya.py108
-rw-r--r--library/python/pytest/rewrite.py20
-rw-r--r--library/python/testing/yatest_common/yatest/common/runtime.py4
-rw-r--r--util/folder/path.pxd186
-rw-r--r--util/folder/path_ut.pyx758
-rw-r--r--util/generic/deque.pxd18
-rw-r--r--util/generic/deque_ut.pyx132
-rw-r--r--util/generic/hash.pxd40
-rw-r--r--util/generic/hash_set_ut.pyx2
-rw-r--r--util/generic/hash_ut.pyx4
-rw-r--r--util/generic/ptr.pxd24
-rw-r--r--util/generic/string.pxd4
-rw-r--r--util/generic/string_ut.pyx74
-rw-r--r--util/generic/vector_ut.pyx16
-rw-r--r--util/memory/blob.pxd82
-rw-r--r--util/memory/blob_ut.pyx282
-rw-r--r--util/stream/output.pxd24
-rw-r--r--util/stream/str.pxd24
-rw-r--r--util/stream/str_ut.pyx124
-rw-r--r--util/string/cast_ut.pyx4
-rw-r--r--util/tests/cython/test_folder.py24
-rw-r--r--util/tests/cython/test_generic.py14
-rw-r--r--util/tests/cython/test_memory.py24
-rw-r--r--util/tests/cython/test_stream.py24
-rw-r--r--util/tests/cython/ya.make18
-rw-r--r--ydb/core/blobstorage/ut_blobstorage/lib/env.h2
-rw-r--r--ydb/core/blobstorage/vdisk/skeleton/skeleton_capturevdisklayout.h4
-rw-r--r--ydb/core/util/stlog.h4
41 files changed, 1241 insertions, 1241 deletions
diff --git a/contrib/python/pytest/py2/_pytest/python.py b/contrib/python/pytest/py2/_pytest/python.py
index 4ceb01a7e4..f7c368b0c4 100644
--- a/contrib/python/pytest/py2/_pytest/python.py
+++ b/contrib/python/pytest/py2/_pytest/python.py
@@ -896,7 +896,7 @@ class CallSpec2(object):
@property
def id(self):
- return "-".join(map(safe_str, self._idlist))
+ return "-".join(map(safe_str, self._idlist))
def setmulti2(self, valtypes, argnames, valset, id, marks, scopenum, param_index):
for arg, val in zip(argnames, valset):
diff --git a/contrib/python/pytest/py2/patches/08-backport-pr-6607.patch b/contrib/python/pytest/py2/patches/08-backport-pr-6607.patch
index 5e8fcb70ae..8d0ae7a5fb 100644
--- a/contrib/python/pytest/py2/patches/08-backport-pr-6607.patch
+++ b/contrib/python/pytest/py2/patches/08-backport-pr-6607.patch
@@ -1,17 +1,17 @@
-commit 46b46cea857997531a7b9b4de32556be50bd5aea (HEAD -> pytest-backport-pr-6607)
-author: danila-eremin
-date: 2022-01-22T16:55:07+03:00
+commit 46b46cea857997531a7b9b4de32556be50bd5aea (HEAD -> pytest-backport-pr-6607)
+author: danila-eremin
+date: 2022-01-22T16:55:07+03:00
+
+ backport py2
+
+--- contrib/python/pytest/py2/_pytest/python.py (b87553999455f0084413c5b59139aa9ccb5e3f52)
++++ contrib/python/pytest/py2/_pytest/python.py (46b46cea857997531a7b9b4de32556be50bd5aea)
+@@ -896,7 +896,7 @@ class CallSpec2(object):
- backport py2
+ @property
+ def id(self):
+- return "-".join(map(safe_str, filter(None, self._idlist)))
++ return "-".join(map(safe_str, self._idlist))
---- contrib/python/pytest/py2/_pytest/python.py (b87553999455f0084413c5b59139aa9ccb5e3f52)
-+++ contrib/python/pytest/py2/_pytest/python.py (46b46cea857997531a7b9b4de32556be50bd5aea)
-@@ -896,7 +896,7 @@ class CallSpec2(object):
-
- @property
- def id(self):
-- return "-".join(map(safe_str, filter(None, self._idlist)))
-+ return "-".join(map(safe_str, self._idlist))
-
- def setmulti2(self, valtypes, argnames, valset, id, marks, scopenum, param_index):
- for arg, val in zip(argnames, valset):
+ def setmulti2(self, valtypes, argnames, valset, id, marks, scopenum, param_index):
+ for arg, val in zip(argnames, valset):
diff --git a/contrib/python/ya.make b/contrib/python/ya.make
index 2898a62f37..d01ced9f3a 100644
--- a/contrib/python/ya.make
+++ b/contrib/python/ya.make
@@ -755,7 +755,7 @@ RECURSE(
portalocker
portpicker
ppdeep
- pq
+ pq
pql
prance
premailer
diff --git a/contrib/restricted/boost/boost/multiprecision/cpp_int.hpp b/contrib/restricted/boost/boost/multiprecision/cpp_int.hpp
index 7f2490feee..8490541159 100644
--- a/contrib/restricted/boost/boost/multiprecision/cpp_int.hpp
+++ b/contrib/restricted/boost/boost/multiprecision/cpp_int.hpp
@@ -467,13 +467,13 @@ public:
BOOST_CONSTEXPR cpp_int_base(const cpp_int_base& a, const literals::detail::negate_tag&)
: m_wrapper(a.m_wrapper), m_limbs(a.m_limbs), m_sign((a.m_limbs == 1) && (*a.limbs() == 0) ? false : !a.m_sign) {}
#endif
-#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
+#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
+ //
+ // These are deprecated in C++20 unless we make them explicit:
+ //
+ constexpr cpp_int_base& operator=(const cpp_int_base&) = default;
+#endif
//
- // These are deprecated in C++20 unless we make them explicit:
- //
- constexpr cpp_int_base& operator=(const cpp_int_base&) = default;
-#endif
- //
// Helper functions for getting at our internal data, and manipulating storage:
//
BOOST_MP_FORCEINLINE unsigned size()const BOOST_NOEXCEPT { return m_limbs; }
@@ -651,12 +651,12 @@ public:
: m_wrapper(o.m_wrapper), m_limbs(o.m_limbs) {}
// Defaulted functions:
//~cpp_int_base() BOOST_NOEXCEPT {}
-#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
- //
- // These are deprecated in C++20 unless we make them explicit:
- //
- constexpr cpp_int_base& operator=(const cpp_int_base&) = default;
-#endif
+#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
+ //
+ // These are deprecated in C++20 unless we make them explicit:
+ //
+ constexpr cpp_int_base& operator=(const cpp_int_base&) = default;
+#endif
BOOST_MP_FORCEINLINE void assign(const cpp_int_base& o) BOOST_NOEXCEPT
{
@@ -820,13 +820,13 @@ public:
BOOST_CONSTEXPR cpp_int_base(const cpp_int_base& a, const literals::detail::negate_tag&)BOOST_NOEXCEPT
: m_data(a.m_data), m_sign(a.m_data ? !a.m_sign : false) {}
#endif
-#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
+#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
+ //
+ // These are deprecated in C++20 unless we make them explicit:
+ //
+ constexpr cpp_int_base& operator=(const cpp_int_base&) = default;
+#endif
//
- // These are deprecated in C++20 unless we make them explicit:
- //
- constexpr cpp_int_base& operator=(const cpp_int_base&) = default;
-#endif
- //
// Helper functions for getting at our internal data, and manipulating storage:
//
BOOST_MP_FORCEINLINE BOOST_CONSTEXPR unsigned size()const BOOST_NOEXCEPT { return 1; }
@@ -983,13 +983,13 @@ public:
BOOST_CONSTEXPR cpp_int_base(literals::detail::value_pack<a, b>) BOOST_NOEXCEPT
: m_data(static_cast<local_limb_type>(a) | (static_cast<local_limb_type>(b) << bits_per_limb)) {}
#endif
-#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
+#ifndef BOOST_MP_NO_CONSTEXPR_DETECTION
+ //
+ // These are deprecated in C++20 unless we make them explicit:
+ //
+ constexpr cpp_int_base& operator=(const cpp_int_base&) = default;
+#endif
//
- // These are deprecated in C++20 unless we make them explicit:
- //
- constexpr cpp_int_base& operator=(const cpp_int_base&) = default;
-#endif
- //
// Helper functions for getting at our internal data, and manipulating storage:
//
BOOST_MP_FORCEINLINE BOOST_CONSTEXPR unsigned size()const BOOST_NOEXCEPT { return 1; }
diff --git a/contrib/restricted/boost/boost/regex/v4/regex_token_iterator.hpp b/contrib/restricted/boost/boost/regex/v4/regex_token_iterator.hpp
index 9b46576a64..d44b9457df 100644
--- a/contrib/restricted/boost/boost/regex/v4/regex_token_iterator.hpp
+++ b/contrib/restricted/boost/boost/regex/v4/regex_token_iterator.hpp
@@ -66,8 +66,8 @@ class regex_token_iterator_implementation
std::vector<int> subs; // the sub-expressions to enumerate
public:
- regex_token_iterator_implementation(const regex_token_iterator_implementation& other)
- : what(other.what), base(other.base), end(other.end), re(other.re), flags(other.flags), result(other.result), N(other.N), subs(other.subs) {}
+ regex_token_iterator_implementation(const regex_token_iterator_implementation& other)
+ : what(other.what), base(other.base), end(other.end), re(other.re), flags(other.flags), result(other.result), N(other.N), subs(other.subs) {}
regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, int sub, match_flag_type f)
: end(last), re(*p), flags(f){ subs.push_back(sub); }
regex_token_iterator_implementation(const regex_type* p, BidirectionalIterator last, const std::vector<int>& v, match_flag_type f)
diff --git a/contrib/tools/bison/bison/data/lalr1.cc b/contrib/tools/bison/bison/data/lalr1.cc
index 56df7a53a2..f4f51c78c7 100644
--- a/contrib/tools/bison/bison/data/lalr1.cc
+++ b/contrib/tools/bison/bison/data/lalr1.cc
@@ -307,8 +307,8 @@ b4_location_define])])[
typedef basic_symbol<by_state> super_type;
/// Construct an empty symbol.
stack_symbol_type ();
- /// Copy construct.
- stack_symbol_type (const stack_symbol_type& that);
+ /// Copy construct.
+ stack_symbol_type (const stack_symbol_type& that);
/// Steal the contents from \a sym to build this.
stack_symbol_type (state_type s, symbol_type& sym);
/// Assignment, needed by push_back.
@@ -566,13 +566,13 @@ m4_if(b4_prefix, [yy], [],
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type ()
{}
- ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that)
- : super_type (that.state]b4_locations_if([, that.location])[)
- {
- ]b4_variant_if([b4_symbol_variant([that.type_get ()],
- [value], [copy], [that.value])],
- [[value = that.value;]])[
- }
+ ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that)
+ : super_type (that.state]b4_locations_if([, that.location])[)
+ {
+ ]b4_variant_if([b4_symbol_variant([that.type_get ()],
+ [value], [copy], [that.value])],
+ [[value = that.value;]])[
+ }
inline
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that)
diff --git a/library/cpp/digest/md5/bench/main.cpp b/library/cpp/digest/md5/bench/main.cpp
index e633a64704..70672e6741 100644
--- a/library/cpp/digest/md5/bench/main.cpp
+++ b/library/cpp/digest/md5/bench/main.cpp
@@ -1,15 +1,15 @@
-#include <benchmark/benchmark.h>
-
+#include <benchmark/benchmark.h>
+
#include <library/cpp/digest/md5/md5.h>
#define MD5_DEF(N) \
- static void MD5Benchmark_##N(benchmark::State& st) { \
+ static void MD5Benchmark_##N(benchmark::State& st) { \
char buf[N]; \
- for (auto _ : st) { \
+ for (auto _ : st) { \
Y_DO_NOT_OPTIMIZE_AWAY(MD5().Update(buf, sizeof(buf))); \
} \
- } \
- BENCHMARK(MD5Benchmark_##N);
+ } \
+ BENCHMARK(MD5Benchmark_##N);
MD5_DEF(32)
MD5_DEF(64)
diff --git a/library/cpp/digest/md5/bench/ya.make b/library/cpp/digest/md5/bench/ya.make
index 0c7211f82a..5c3e3c1c42 100644
--- a/library/cpp/digest/md5/bench/ya.make
+++ b/library/cpp/digest/md5/bench/ya.make
@@ -1,4 +1,4 @@
-G_BENCHMARK()
+G_BENCHMARK()
OWNER(
pg
diff --git a/library/cpp/digest/md5/md5.cpp b/library/cpp/digest/md5/md5.cpp
index b10e63e425..24a5b69eef 100644
--- a/library/cpp/digest/md5/md5.cpp
+++ b/library/cpp/digest/md5/md5.cpp
@@ -1,17 +1,17 @@
#include "md5.h"
-#include <library/cpp/string_utils/base64/base64.h>
+#include <library/cpp/string_utils/base64/base64.h>
#include <util/stream/input.h>
#include <util/stream/file.h>
#include <util/string/hex.h>
-#include <contrib/libs/nayuki_md5/md5.h>
+#include <contrib/libs/nayuki_md5/md5.h>
namespace {
- constexpr size_t MD5_BLOCK_LENGTH = 64;
- constexpr size_t MD5_PADDING_SHIFT = 56;
+ constexpr size_t MD5_BLOCK_LENGTH = 64;
+ constexpr size_t MD5_PADDING_SHIFT = 56;
constexpr size_t MD5_HEX_DIGEST_LENGTH = 32;
struct TMd5Stream: public IOutputStream {
@@ -26,14 +26,14 @@ namespace {
MD5* M_;
};
-
- inline TArrayRef<const ui8> MakeUnsignedArrayRef(const void* data, const size_t size) {
- return MakeArrayRef(static_cast<const ui8*>(data), size);
- }
-
- inline TArrayRef<const ui8> MakeUnsignedArrayRef(const TArrayRef<const char>& data) {
- return MakeUnsignedArrayRef(data.data(), data.size());
- }
+
+ inline TArrayRef<const ui8> MakeUnsignedArrayRef(const void* data, const size_t size) {
+ return MakeArrayRef(static_cast<const ui8*>(data), size);
+ }
+
+ inline TArrayRef<const ui8> MakeUnsignedArrayRef(const TArrayRef<const char>& data) {
+ return MakeUnsignedArrayRef(data.data(), data.size());
+ }
}
char* MD5::File(const char* filename, char* buf) {
@@ -57,23 +57,23 @@ TString MD5::File(const TString& filename) {
return buf;
}
-char* MD5::Data(const TArrayRef<const ui8>& data, char* buf) {
- return MD5().Update(data).End(buf);
-}
-
+char* MD5::Data(const TArrayRef<const ui8>& data, char* buf) {
+ return MD5().Update(data).End(buf);
+}
+
char* MD5::Data(const void* data, size_t len, char* buf) {
- return Data(MakeUnsignedArrayRef(data, len), buf);
+ return Data(MakeUnsignedArrayRef(data, len), buf);
}
-TString MD5::Data(const TArrayRef<const ui8>& data) {
+TString MD5::Data(const TArrayRef<const ui8>& data) {
TString buf;
buf.ReserveAndResize(MD5_HEX_DIGEST_LENGTH);
- Data(data, buf.begin());
+ Data(data, buf.begin());
return buf;
}
TString MD5::Data(TStringBuf data) {
- return Data(MakeUnsignedArrayRef(data));
+ return Data(MakeUnsignedArrayRef(data));
}
char* MD5::Stream(IInputStream* in, char* buf) {
@@ -88,7 +88,7 @@ MD5& MD5::Update(IInputStream* in) {
return *this;
}
-static const ui8 PADDING[MD5_BLOCK_LENGTH] = {
+static const ui8 PADDING[MD5_BLOCK_LENGTH] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
@@ -96,8 +96,8 @@ static const ui8 PADDING[MD5_BLOCK_LENGTH] = {
/* MD5 initialization. Begins an MD5 operation, writing a new context. */
void MD5::Init() {
- BufferSize = 0;
- StreamSize = 0;
+ BufferSize = 0;
+ StreamSize = 0;
/* Load magic initialization constants. */
State[0] = 0x67452301;
State[1] = 0xefcdab89;
@@ -111,30 +111,30 @@ void MD5::Init() {
* context.
*/
-void MD5::UpdatePart(TArrayRef<const ui8> data) {
- /* Count input bytes */
- StreamSize += data.size();
- if (BufferSize > 0) {
- /* Filling remaining buffer */
- const ui8 freeBufferSize = MD5_BLOCK_LENGTH - BufferSize;
- const ui8 partLen = data.size() >= freeBufferSize ? freeBufferSize : data.size();
- memcpy(&Buffer[BufferSize], data.data(), partLen);
- BufferSize += partLen;
- data = data.Slice(partLen);
- if (BufferSize == MD5_BLOCK_LENGTH) {
- /* Buffer is full and ready for hashing */
- md5_compress(State, Buffer);
- BufferSize = 0;
- }
- }
- /* Processing input by chanks */
- while (data.size() >= MD5_BLOCK_LENGTH) {
- md5_compress(State, data.data());
- data = data.Slice(MD5_BLOCK_LENGTH);
- }
- /* Save remaining input in buffer */
- memcpy(Buffer, data.data(), data.size());
- BufferSize += data.size();
+void MD5::UpdatePart(TArrayRef<const ui8> data) {
+ /* Count input bytes */
+ StreamSize += data.size();
+ if (BufferSize > 0) {
+ /* Filling remaining buffer */
+ const ui8 freeBufferSize = MD5_BLOCK_LENGTH - BufferSize;
+ const ui8 partLen = data.size() >= freeBufferSize ? freeBufferSize : data.size();
+ memcpy(&Buffer[BufferSize], data.data(), partLen);
+ BufferSize += partLen;
+ data = data.Slice(partLen);
+ if (BufferSize == MD5_BLOCK_LENGTH) {
+ /* Buffer is full and ready for hashing */
+ md5_compress(State, Buffer);
+ BufferSize = 0;
+ }
+ }
+ /* Processing input by chanks */
+ while (data.size() >= MD5_BLOCK_LENGTH) {
+ md5_compress(State, data.data());
+ data = data.Slice(MD5_BLOCK_LENGTH);
+ }
+ /* Save remaining input in buffer */
+ memcpy(Buffer, data.data(), data.size());
+ BufferSize += data.size();
}
/*
@@ -142,19 +142,19 @@ void MD5::UpdatePart(TArrayRef<const ui8> data) {
*/
void MD5::Pad() {
- size_t streamSize = StreamSize;
-
- const size_t paddingSize = (MD5_PADDING_SHIFT > BufferSize) ? (MD5_PADDING_SHIFT - BufferSize) : (MD5_PADDING_SHIFT + MD5_BLOCK_LENGTH - BufferSize);
- Update(PADDING, paddingSize);
-
- // Size of stream in bits
- // If size greater than 2^64 - 1 only lower 64 bits used
- streamSize <<= 3;
- for (int i = 0; i < 8; ++i, streamSize >>= 8) {
- // Storing in reverse order
- Buffer[MD5_PADDING_SHIFT + i] = static_cast<ui8>(streamSize & 0xFFU);
- }
- md5_compress(State, Buffer);
+ size_t streamSize = StreamSize;
+
+ const size_t paddingSize = (MD5_PADDING_SHIFT > BufferSize) ? (MD5_PADDING_SHIFT - BufferSize) : (MD5_PADDING_SHIFT + MD5_BLOCK_LENGTH - BufferSize);
+ Update(PADDING, paddingSize);
+
+ // Size of stream in bits
+ // If size greater than 2^64 - 1 only lower 64 bits used
+ streamSize <<= 3;
+ for (int i = 0; i < 8; ++i, streamSize >>= 8) {
+ // Storing in reverse order
+ Buffer[MD5_PADDING_SHIFT + i] = static_cast<ui8>(streamSize & 0xFFU);
+ }
+ md5_compress(State, Buffer);
}
/*
@@ -162,35 +162,35 @@ void MD5::Pad() {
* the message digest and zeroizing the context.
*/
-ui8* MD5::Final(ui8 digest[16]) {
+ui8* MD5::Final(ui8 digest[16]) {
/* Do padding. */
Pad();
/* Store state in digest */
- memcpy(digest, State, 16);
+ memcpy(digest, State, 16);
/* Zeroize sensitive information. */
- Init();
+ Init();
return digest;
}
char* MD5::End(char* buf) {
static const char hex[] = "0123456789abcdef";
- ui8 digest[16];
+ ui8 digest[16];
if (!buf)
buf = (char*)malloc(33);
if (!buf)
return nullptr;
Final(digest);
- for (ui8 i = 0; i < MD5_HEX_DIGEST_LENGTH / 2; i++) {
- buf[i * 2] = hex[digest[i] >> 4];
- buf[i * 2 + 1] = hex[digest[i] & 0x0f];
+ for (ui8 i = 0; i < MD5_HEX_DIGEST_LENGTH / 2; i++) {
+ buf[i * 2] = hex[digest[i] >> 4];
+ buf[i * 2 + 1] = hex[digest[i] & 0x0f];
}
- buf[32] = '\0';
+ buf[32] = '\0';
return buf;
}
char* MD5::End_b64(char* buf) {
- ui8 digest[16];
+ ui8 digest[16];
if (!buf)
buf = (char*)malloc(25);
if (!buf)
@@ -202,7 +202,7 @@ char* MD5::End_b64(char* buf) {
}
ui64 MD5::EndHalfMix() {
- ui8 digest[16];
+ ui8 digest[16];
Final(digest);
ui64 res = 0;
for (int i = 3; i >= 0; i--) {
@@ -212,47 +212,47 @@ ui64 MD5::EndHalfMix() {
return res;
}
-TString MD5::Calc(TStringBuf data) {
- return Calc(MakeUnsignedArrayRef(data));
-}
+TString MD5::Calc(TStringBuf data) {
+ return Calc(MakeUnsignedArrayRef(data));
+}
-TString MD5::Calc(const TArrayRef<const ui8>& data) {
- return Data(data);
-}
+TString MD5::Calc(const TArrayRef<const ui8>& data) {
+ return Data(data);
+}
-TString MD5::CalcRaw(TStringBuf data) {
- return CalcRaw(MakeUnsignedArrayRef(data));
+TString MD5::CalcRaw(TStringBuf data) {
+ return CalcRaw(MakeUnsignedArrayRef(data));
}
-TString MD5::CalcRaw(const TArrayRef<const ui8>& data) {
+TString MD5::CalcRaw(const TArrayRef<const ui8>& data) {
TString result;
- result.ReserveAndResize(16);
- MD5().Update(data).Final(reinterpret_cast<ui8*>(result.begin()));
+ result.ReserveAndResize(16);
+ MD5().Update(data).Final(reinterpret_cast<ui8*>(result.begin()));
return result;
}
ui64 MD5::CalcHalfMix(const char* data, size_t len) {
- return CalcHalfMix(MakeUnsignedArrayRef(data, len));
+ return CalcHalfMix(MakeUnsignedArrayRef(data, len));
+}
+
+ui64 MD5::CalcHalfMix(TStringBuf data) {
+ return CalcHalfMix(MakeUnsignedArrayRef(data));
+}
+
+ui64 MD5::CalcHalfMix(const TArrayRef<const ui8>& data) {
+ return MD5().Update(data).EndHalfMix();
}
-ui64 MD5::CalcHalfMix(TStringBuf data) {
- return CalcHalfMix(MakeUnsignedArrayRef(data));
+bool MD5::IsMD5(TStringBuf data) {
+ return IsMD5(MakeUnsignedArrayRef(data));
}
-ui64 MD5::CalcHalfMix(const TArrayRef<const ui8>& data) {
- return MD5().Update(data).EndHalfMix();
-}
-
-bool MD5::IsMD5(TStringBuf data) {
- return IsMD5(MakeUnsignedArrayRef(data));
-}
-
-bool MD5::IsMD5(const TArrayRef<const ui8>& data) {
+bool MD5::IsMD5(const TArrayRef<const ui8>& data) {
if (data.size() != 32) {
return false;
}
- for (const ui8 *p = data.data(), *e = data.data() + data.size(); p != e; ++p) {
- if (Char2DigitTable[*p] == '\xff') {
+ for (const ui8 *p = data.data(), *e = data.data() + data.size(); p != e; ++p) {
+ if (Char2DigitTable[*p] == '\xff') {
return false;
}
}
diff --git a/library/cpp/digest/md5/md5.h b/library/cpp/digest/md5/md5.h
index 6dea247e3d..2c17aa0518 100644
--- a/library/cpp/digest/md5/md5.h
+++ b/library/cpp/digest/md5/md5.h
@@ -14,20 +14,20 @@ public:
void Init();
inline MD5& Update(const void* data, size_t len) {
- return Update(MakeArrayRef(static_cast<const ui8*>(data), len));
- }
+ return Update(MakeArrayRef(static_cast<const ui8*>(data), len));
+ }
- inline MD5& Update(TStringBuf data) {
- return Update(data.data(), data.size());
- }
+ inline MD5& Update(TStringBuf data) {
+ return Update(data.data(), data.size());
+ }
- inline MD5& Update(const TArrayRef<const ui8> data) {
- UpdatePart(data);
+ inline MD5& Update(const TArrayRef<const ui8> data) {
+ UpdatePart(data);
return *this;
}
void Pad();
- ui8* Final(ui8[16]);
+ ui8* Final(ui8[16]);
// buf must be char[33];
char* End(char* buf);
@@ -49,29 +49,29 @@ public:
static TString File(const TString& filename);
static char* Data(const void* data, size_t len, char* buf);
- static char* Data(const TArrayRef<const ui8>& data, char* buf);
- static TString Data(const TArrayRef<const ui8>& data);
+ static char* Data(const TArrayRef<const ui8>& data, char* buf);
+ static TString Data(const TArrayRef<const ui8>& data);
static TString Data(TStringBuf data);
static char* Stream(IInputStream* in, char* buf);
- static TString Calc(TStringBuf data); // 32-byte hex-encoded
- static TString Calc(const TArrayRef<const ui8>& data); // 32-byte hex-encoded
- static TString CalcRaw(TStringBuf data); // 16-byte raw
- static TString CalcRaw(const TArrayRef<const ui8>& data); // 16-byte raw
+ static TString Calc(TStringBuf data); // 32-byte hex-encoded
+ static TString Calc(const TArrayRef<const ui8>& data); // 32-byte hex-encoded
+ static TString CalcRaw(TStringBuf data); // 16-byte raw
+ static TString CalcRaw(const TArrayRef<const ui8>& data); // 16-byte raw
- static ui64 CalcHalfMix(TStringBuf data);
- static ui64 CalcHalfMix(const TArrayRef<const ui8>& data);
+ static ui64 CalcHalfMix(TStringBuf data);
+ static ui64 CalcHalfMix(const TArrayRef<const ui8>& data);
static ui64 CalcHalfMix(const char* data, size_t len);
- static bool IsMD5(TStringBuf data);
- static bool IsMD5(const TArrayRef<const ui8>& data);
+ static bool IsMD5(TStringBuf data);
+ static bool IsMD5(const TArrayRef<const ui8>& data);
private:
- void UpdatePart(TArrayRef<const ui8> data);
+ void UpdatePart(TArrayRef<const ui8> data);
private:
- ui8 BufferSize; /* size of buffer */
- ui8 Buffer[64]; /* input buffer */
- ui32 State[4]; /* state (ABCD) */
- ui64 StreamSize; /* total bytes in input stream */
+ ui8 BufferSize; /* size of buffer */
+ ui8 Buffer[64]; /* input buffer */
+ ui32 State[4]; /* state (ABCD) */
+ ui64 StreamSize; /* total bytes in input stream */
};
diff --git a/library/cpp/digest/md5/md5_ut.cpp b/library/cpp/digest/md5/md5_ut.cpp
index 3b596d9d74..1c3e4ad0a9 100644
--- a/library/cpp/digest/md5/md5_ut.cpp
+++ b/library/cpp/digest/md5/md5_ut.cpp
@@ -18,11 +18,11 @@ Y_UNIT_TEST_SUITE(TMD5Test) {
TString s(r.End(rs));
s.to_lower();
- UNIT_ASSERT_NO_DIFF(s, TStringBuf("3ac00dd696b966fd74deee3c35a59d8f"));
+ UNIT_ASSERT_NO_DIFF(s, TStringBuf("3ac00dd696b966fd74deee3c35a59d8f"));
TString result = r.Calc(TStringBuf(b));
result.to_lower();
- UNIT_ASSERT_NO_DIFF(result, TStringBuf("3ac00dd696b966fd74deee3c35a59d8f"));
+ UNIT_ASSERT_NO_DIFF(result, TStringBuf("3ac00dd696b966fd74deee3c35a59d8f"));
}
Y_UNIT_TEST(TestFile) {
@@ -39,10 +39,10 @@ Y_UNIT_TEST_SUITE(TMD5Test) {
TString fileHash = MD5::File(tmpFile.data(), fileBuf);
TString memoryHash = MD5::Data((const unsigned char*)s.data(), s.size(), memBuf);
- UNIT_ASSERT_NO_DIFF(fileHash, memoryHash);
+ UNIT_ASSERT_NO_DIFF(fileHash, memoryHash);
fileHash = MD5::File(tmpFile);
- UNIT_ASSERT_NO_DIFF(fileHash, memoryHash);
+ UNIT_ASSERT_NO_DIFF(fileHash, memoryHash);
NFs::Remove(tmpFile);
fileHash = MD5::File(tmpFile);
diff --git a/library/cpp/tvmauth/client/ut/settings_ut.cpp b/library/cpp/tvmauth/client/ut/settings_ut.cpp
index dbb04272a1..76c9542442 100644
--- a/library/cpp/tvmauth/client/ut/settings_ut.cpp
+++ b/library/cpp/tvmauth/client/ut/settings_ut.cpp
@@ -37,7 +37,7 @@ Y_UNIT_TEST_SUITE(ClientSettings) {
TTestCase{
.Name = "dsts with selfTvmId",
.Settings = {
- .SelfTvmId = 43,
+ .SelfTvmId = 43,
.FetchServiceTicketsForDsts = {42},
},
.Err = "Secret is required for fetching of Service Tickets",
@@ -47,7 +47,7 @@ Y_UNIT_TEST_SUITE(ClientSettings) {
.Settings = {
.SelfTvmId = 43,
.Secret = TStringBuf("foobar"),
- .FetchServiceTicketsForDsts = {42},
+ .FetchServiceTicketsForDsts = {42},
},
.Err = "",
},
diff --git a/library/python/pytest/plugins/collection.py b/library/python/pytest/plugins/collection.py
index 9c29494de8..e36f47a78f 100644
--- a/library/python/pytest/plugins/collection.py
+++ b/library/python/pytest/plugins/collection.py
@@ -12,40 +12,40 @@ import library.python.testing.filter.filter as test_filter
class LoadedModule(_pytest.python.Module):
- def __init__(self, parent, name, **kwargs):
- self.name = name + '.py'
- self.session = parent
- self.parent = parent
- self.config = parent.config
+ def __init__(self, parent, name, **kwargs):
+ self.name = name + '.py'
+ self.session = parent
+ self.parent = parent
+ self.config = parent.config
self.keywords = {}
self.own_markers = []
- self.fspath = py.path.local()
-
- @classmethod
- def from_parent(cls, **kwargs):
- namespace = kwargs.pop('namespace', True)
- kwargs.setdefault('fspath', py.path.local())
-
- loaded_module = getattr(super(LoadedModule, cls), 'from_parent', cls)(**kwargs)
- loaded_module.namespace = namespace
-
- return loaded_module
-
+ self.fspath = py.path.local()
+
+ @classmethod
+ def from_parent(cls, **kwargs):
+ namespace = kwargs.pop('namespace', True)
+ kwargs.setdefault('fspath', py.path.local())
+
+ loaded_module = getattr(super(LoadedModule, cls), 'from_parent', cls)(**kwargs)
+ loaded_module.namespace = namespace
+
+ return loaded_module
+
@property
- def _nodeid(self):
- if os.getenv('CONFTEST_LOAD_POLICY') == 'LOCAL':
+ def _nodeid(self):
+ if os.getenv('CONFTEST_LOAD_POLICY') == 'LOCAL':
return self._getobj().__file__
else:
return self.name
-
- @property
- def nodeid(self):
- return self._nodeid
+
+ @property
+ def nodeid(self):
+ return self._nodeid
def _getobj(self):
- module_name = self.name[:-len('.py')]
+ module_name = self.name[:-len('.py')]
if self.namespace:
- module_name = '__tests__.' + module_name
+ module_name = '__tests__.' + module_name
__import__(module_name)
return sys.modules[module_name]
@@ -62,19 +62,19 @@ class DoctestModule(LoadedModule):
runner = doctest.DebugRunner(verbose=0, optionflags=optionflags)
try:
- for test in finder.find(module, self.name[:-len('.py')]):
+ for test in finder.find(module, self.name[:-len('.py')]):
if test.examples: # skip empty doctests
- yield getattr(_pytest.doctest.DoctestItem, 'from_parent', _pytest.doctest.DoctestItem)(
- name=test.name,
- parent=self,
- runner=runner,
- dtest=test)
+ yield getattr(_pytest.doctest.DoctestItem, 'from_parent', _pytest.doctest.DoctestItem)(
+ name=test.name,
+ parent=self,
+ runner=runner,
+ dtest=test)
except Exception:
import logging
logging.exception('DoctestModule failed, probably you can add NO_DOCTESTS() macro to ya.make')
etype, exc, tb = sys.exc_info()
msg = 'DoctestModule failed, probably you can add NO_DOCTESTS() macro to ya.make'
- reraise(etype, type(exc)('{}\n{}'.format(exc, msg)), tb)
+ reraise(etype, type(exc)('{}\n{}'.format(exc, msg)), tb)
# NOTE: Since we are overriding collect method of pytest session, pytest hooks are not invoked during collection.
@@ -88,7 +88,7 @@ def pytest_ignore_collect(module, session, filenames_from_full_filters, accept_f
test_file_filter = getattr(session.config.option, 'test_file_filter', None)
if test_file_filter is None:
return False
- if module.name != test_file_filter.replace('/', '.'):
+ if module.name != test_file_filter.replace('/', '.'):
return True
return False
@@ -112,17 +112,17 @@ class CollectionPlugin(object):
filenames_filter = set(map(lambda x: x.split('::')[0], full_names_filter))
for test_module in self._test_modules:
- module = LoadedModule.from_parent(name=test_module, parent=session)
+ module = LoadedModule.from_parent(name=test_module, parent=session)
if not pytest_ignore_collect(module, session, filenames_filter, accept_filename_predicate):
yield module
if os.environ.get('YA_PYTEST_DISABLE_DOCTEST', 'no') == 'no':
- module = DoctestModule.from_parent(name=test_module, parent=session)
+ module = DoctestModule.from_parent(name=test_module, parent=session)
if not pytest_ignore_collect(module, session, filenames_filter, accept_filename_predicate):
yield module
if os.environ.get('YA_PYTEST_DISABLE_DOCTEST', 'no') == 'no':
for doctest_module in self._doctest_modules:
- yield DoctestModule.from_parent(name=doctest_module, parent=session, namespace=False)
+ yield DoctestModule.from_parent(name=doctest_module, parent=session, namespace=False)
session.collect = collect
diff --git a/library/python/pytest/plugins/ya.py b/library/python/pytest/plugins/ya.py
index dae99f41d5..1bde03042d 100644
--- a/library/python/pytest/plugins/ya.py
+++ b/library/python/pytest/plugins/ya.py
@@ -23,9 +23,9 @@ import six
import _pytest
import _pytest._io
-import _pytest.mark
+import _pytest.mark
import _pytest.outcomes
-import _pytest.skipping
+import _pytest.skipping
from _pytest.warning_types import PytestUnhandledCoroutineWarning
@@ -293,38 +293,38 @@ def pytest_configure(config):
signal.signal(signal.SIGUSR2, _graceful_shutdown)
-session_should_exit = False
-
-
-def _graceful_shutdown_on_log(should_exit):
- if should_exit:
- pytest.exit("Graceful shutdown requested")
-
-
-def pytest_runtest_logreport(report):
- _graceful_shutdown_on_log(session_should_exit)
-
-
-def pytest_runtest_logstart(nodeid, location):
- _graceful_shutdown_on_log(session_should_exit)
-
-
-def pytest_runtest_logfinish(nodeid, location):
- _graceful_shutdown_on_log(session_should_exit)
-
-
+session_should_exit = False
+
+
+def _graceful_shutdown_on_log(should_exit):
+ if should_exit:
+ pytest.exit("Graceful shutdown requested")
+
+
+def pytest_runtest_logreport(report):
+ _graceful_shutdown_on_log(session_should_exit)
+
+
+def pytest_runtest_logstart(nodeid, location):
+ _graceful_shutdown_on_log(session_should_exit)
+
+
+def pytest_runtest_logfinish(nodeid, location):
+ _graceful_shutdown_on_log(session_should_exit)
+
+
def _graceful_shutdown(*args):
- global session_should_exit
- session_should_exit = True
+ global session_should_exit
+ session_should_exit = True
try:
import library.python.coverage
library.python.coverage.stop_coverage_tracing()
except ImportError:
pass
traceback.print_stack(file=sys.stderr)
- capman = pytest_config.pluginmanager.getplugin("capturemanager")
- capman.suspend(in_=True)
- _graceful_shutdown_on_log(not capman.is_globally_capturing())
+ capman = pytest_config.pluginmanager.getplugin("capturemanager")
+ capman.suspend(in_=True)
+ _graceful_shutdown_on_log(not capman.is_globally_capturing())
def _get_rusage():
@@ -368,7 +368,7 @@ def _collect_test_rusage(item):
def _get_item_tags(item):
tags = []
for key, value in item.keywords.items():
- if key == 'pytestmark' and isinstance(value, list):
+ if key == 'pytestmark' and isinstance(value, list):
for mark in value:
tags.append(mark.name)
elif isinstance(value, _pytest.mark.MarkDecorator):
@@ -541,7 +541,7 @@ def pytest_pyfunc_call(pyfuncitem):
return True
-@pytest.hookimpl(hookwrapper=True)
+@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
def logreport(report, result, call):
test_item = TestItem(report, result, pytest_config.option.test_suffix)
@@ -550,10 +550,10 @@ def pytest_runtest_makereport(item, call):
pytest_config.ya_trace_reporter.dump_suite_metrics()
pytest_config.ya_trace_reporter.on_log_report(test_item)
-
- if report.outcome == "failed":
- yatest_logger.error(report.longrepr)
-
+
+ if report.outcome == "failed":
+ yatest_logger.error(report.longrepr)
+
if report.when == "call":
_collect_test_rusage(item)
pytest_config.ya_trace_reporter.on_finish_test_case(test_item)
@@ -572,16 +572,16 @@ def pytest_runtest_makereport(item, call):
pytest_config.ya_trace_reporter.on_finish_test_case(test_item, duration_only=True)
pytest_config.ya_trace_reporter.on_finish_test_class(test_item)
- outcome = yield
- rep = outcome.get_result()
- result = None
+ outcome = yield
+ rep = outcome.get_result()
+ result = None
if hasattr(item, 'retval') and item.retval is not None:
result = item.retval
if not pytest_config.from_ya_test:
ti = TestItem(rep, result, pytest_config.option.test_suffix)
tr = pytest_config.pluginmanager.getplugin('terminalreporter')
tr.write_line("{} - Validating canonical data is not supported when running standalone binary".format(ti), yellow=True, bold=True)
- logreport(rep, result, call)
+ logreport(rep, result, call)
def pytest_make_parametrize_id(config, val, argname):
@@ -652,25 +652,25 @@ class TestItem(object):
self.set_error(report.when + " failed:\n" + self._error)
else:
self.set_error("")
-
- report_teststatus = _pytest.skipping.pytest_report_teststatus(report)
- if report_teststatus is not None:
- report_teststatus = report_teststatus[0]
-
- if report_teststatus == 'xfailed':
- self._status = 'xfail'
- self.set_error(report.wasxfail, 'imp')
- elif report_teststatus == 'xpassed':
- self._status = 'xpass'
- self.set_error("Test unexpectedly passed")
- elif report.skipped:
- self._status = 'skipped'
- self.set_error(yatest_lib.tools.to_utf8(report.longrepr[-1]))
- elif report.passed:
+
+ report_teststatus = _pytest.skipping.pytest_report_teststatus(report)
+ if report_teststatus is not None:
+ report_teststatus = report_teststatus[0]
+
+ if report_teststatus == 'xfailed':
+ self._status = 'xfail'
+ self.set_error(report.wasxfail, 'imp')
+ elif report_teststatus == 'xpassed':
+ self._status = 'xpass'
+ self.set_error("Test unexpectedly passed")
+ elif report.skipped:
+ self._status = 'skipped'
+ self.set_error(yatest_lib.tools.to_utf8(report.longrepr[-1]))
+ elif report.passed:
self._status = 'good'
self.set_error("")
- else:
- self._status = 'fail'
+ else:
+ self._status = 'fail'
@property
def status(self):
diff --git a/library/python/pytest/rewrite.py b/library/python/pytest/rewrite.py
index 5171dbd345..4cebcb1edd 100644
--- a/library/python/pytest/rewrite.py
+++ b/library/python/pytest/rewrite.py
@@ -10,12 +10,12 @@ try:
import importlib.util
except ImportError:
pass
-
-try:
- from pathlib import Path
-except ImportError:
- pass
-
+
+try:
+ from pathlib import Path
+except ImportError:
+ pass
+
from __res import importer
import sys
import six
@@ -49,10 +49,10 @@ class AssertionRewritingHook(rewrite.AssertionRewritingHook):
except ImportError:
return None
- if hasattr(self._rewritten_names, 'add'):
- self._rewritten_names.add(name)
- else:
- self._rewritten_names[name] = Path(path[0])
+ if hasattr(self._rewritten_names, 'add'):
+ self._rewritten_names.add(name)
+ else:
+ self._rewritten_names[name] = Path(path[0])
state.trace("rewriting %s" % name)
co = _rewrite_test(self.config, name)
diff --git a/library/python/testing/yatest_common/yatest/common/runtime.py b/library/python/testing/yatest_common/yatest/common/runtime.py
index f1b133a27f..e55e193446 100644
--- a/library/python/testing/yatest_common/yatest/common/runtime.py
+++ b/library/python/testing/yatest_common/yatest/common/runtime.py
@@ -212,7 +212,7 @@ def test_output_path(path=None):
"""
Get dir in the suite output_path for the current test case
"""
- test_out_dir = os.path.splitext(_get_ya_config().current_test_log_path)[0]
+ test_out_dir = os.path.splitext(_get_ya_config().current_test_log_path)[0]
try:
os.makedirs(test_out_dir)
except OSError as e:
@@ -313,7 +313,7 @@ class Context(object):
@property
def test_name(self):
- return _get_ya_config().current_test_name
+ return _get_ya_config().current_test_name
@property
def sanitize(self):
diff --git a/util/folder/path.pxd b/util/folder/path.pxd
index 9a60cd8874..85af10d746 100644
--- a/util/folder/path.pxd
+++ b/util/folder/path.pxd
@@ -1,93 +1,93 @@
-from util.generic.string cimport TString, TStringBuf
-from util.generic.vector cimport TVector
-
-
-# NOTE (danila-eremin) Currently not possible to use `const` and `except +` at the same time, so some function not marked const
-cdef extern from "util/folder/path.h" nogil:
- cdef cppclass TFsPath:
- TFsPath() except +
- TFsPath(const TString&) except +
- TFsPath(const TStringBuf) except +
- TFsPath(const char*) except +
-
- void CheckDefined() except +
-
- bint IsDefined() const
- bint operator bool() const
-
- const char* c_str() const
-
- bint operator==(const TFsPath&) const
- bint operator!=(const TFsPath&) const
-
- # NOTE (danila-eremin) operator `/=` Not supported
- # TFsPath& operator/=(const TFsPath&) const
-
- TFsPath operator/(const TFsPath&, const TFsPath&) except +
-
- # NOTE (danila-eremin) TPathSplit needed
- # const TPathSplit& PathSplit() const
-
- TFsPath& Fix() except +
-
- const TString& GetPath() const
- TString GetName() const
-
- TString GetExtension() const
-
- bint IsAbsolute() const
- bint IsRelative() const
-
- bint IsSubpathOf(const TFsPath&) const
- bint IsNonStrictSubpathOf(const TFsPath&) const
- bint IsContainerOf(const TFsPath&) const
-
- TFsPath RelativeTo(const TFsPath&) except +
- TFsPath RelativePath(const TFsPath&) except +
-
- TFsPath Parent() const
-
- TString Basename() const
- TString Dirname() const
-
- TFsPath Child(const TString&) except +
-
- void MkDir() except +
- void MkDir(const int) except +
- void MkDirs() except +
- void MkDirs(const int) except +
-
- void List(TVector[TFsPath]&) except +
- void ListNames(TVector[TString]&) except +
-
- bint Contains(const TString&) const
-
- void DeleteIfExists() except +
- void ForceDelete() except +
-
- # NOTE (danila-eremin) TFileStat needed
- # bint Stat(TFileStat&) const
-
- bint Exists() const
- bint IsDirectory() const
- bint IsFile() const
- bint IsSymlink() const
- void CheckExists() except +
-
- void RenameTo(const TString&) except +
- void RenameTo(const char*) except +
- void RenameTo(const TFsPath&) except +
- void ForceRenameTo(const TString&) except +
-
- void CopyTo(const TString&, bint) except +
-
- void Touch() except +
-
- TFsPath RealPath() except +
- TFsPath RealLocation() except +
- TFsPath ReadLink() except +
-
- @staticmethod
- TFsPath Cwd() except +
-
- void Swap(TFsPath&)
+from util.generic.string cimport TString, TStringBuf
+from util.generic.vector cimport TVector
+
+
+# NOTE (danila-eremin) Currently not possible to use `const` and `except +` at the same time, so some function not marked const
+cdef extern from "util/folder/path.h" nogil:
+ cdef cppclass TFsPath:
+ TFsPath() except +
+ TFsPath(const TString&) except +
+ TFsPath(const TStringBuf) except +
+ TFsPath(const char*) except +
+
+ void CheckDefined() except +
+
+ bint IsDefined() const
+ bint operator bool() const
+
+ const char* c_str() const
+
+ bint operator==(const TFsPath&) const
+ bint operator!=(const TFsPath&) const
+
+ # NOTE (danila-eremin) operator `/=` Not supported
+ # TFsPath& operator/=(const TFsPath&) const
+
+ TFsPath operator/(const TFsPath&, const TFsPath&) except +
+
+ # NOTE (danila-eremin) TPathSplit needed
+ # const TPathSplit& PathSplit() const
+
+ TFsPath& Fix() except +
+
+ const TString& GetPath() const
+ TString GetName() const
+
+ TString GetExtension() const
+
+ bint IsAbsolute() const
+ bint IsRelative() const
+
+ bint IsSubpathOf(const TFsPath&) const
+ bint IsNonStrictSubpathOf(const TFsPath&) const
+ bint IsContainerOf(const TFsPath&) const
+
+ TFsPath RelativeTo(const TFsPath&) except +
+ TFsPath RelativePath(const TFsPath&) except +
+
+ TFsPath Parent() const
+
+ TString Basename() const
+ TString Dirname() const
+
+ TFsPath Child(const TString&) except +
+
+ void MkDir() except +
+ void MkDir(const int) except +
+ void MkDirs() except +
+ void MkDirs(const int) except +
+
+ void List(TVector[TFsPath]&) except +
+ void ListNames(TVector[TString]&) except +
+
+ bint Contains(const TString&) const
+
+ void DeleteIfExists() except +
+ void ForceDelete() except +
+
+ # NOTE (danila-eremin) TFileStat needed
+ # bint Stat(TFileStat&) const
+
+ bint Exists() const
+ bint IsDirectory() const
+ bint IsFile() const
+ bint IsSymlink() const
+ void CheckExists() except +
+
+ void RenameTo(const TString&) except +
+ void RenameTo(const char*) except +
+ void RenameTo(const TFsPath&) except +
+ void ForceRenameTo(const TString&) except +
+
+ void CopyTo(const TString&, bint) except +
+
+ void Touch() except +
+
+ TFsPath RealPath() except +
+ TFsPath RealLocation() except +
+ TFsPath ReadLink() except +
+
+ @staticmethod
+ TFsPath Cwd() except +
+
+ void Swap(TFsPath&)
diff --git a/util/folder/path_ut.pyx b/util/folder/path_ut.pyx
index 7c1c376556..e2537683ee 100644
--- a/util/folder/path_ut.pyx
+++ b/util/folder/path_ut.pyx
@@ -1,379 +1,379 @@
-# cython: c_string_type=str, c_string_encoding=utf8
-
-from util.folder.path cimport TFsPath
-from util.generic.string cimport TString, TStringBuf
-from util.generic.vector cimport TVector
-
-import unittest
-import yatest.common
-
-import os.path
-
-
-class TestPath(unittest.TestCase):
- def test_ctor1(self):
- cdef TFsPath path = TFsPath()
- self.assertEqual(path.IsDefined(), False)
- self.assertEquals(path.c_str(), "")
-
- def test_ctor2(self):
- cdef TString str_path = "/a/b/c"
- cdef TFsPath path = TFsPath(str_path)
- self.assertEqual(path.IsDefined(), True)
- self.assertEquals(path.c_str(), "/a/b/c")
-
- def test_ctor3(self):
- cdef TStringBuf buf_path = "/a/b/c"
- cdef TFsPath path = TFsPath(buf_path)
- self.assertEqual(path.IsDefined(), True)
- self.assertEquals(path.c_str(), "/a/b/c")
-
- def test_ctor4(self):
- cdef char* char_path = "/a/b/c"
- cdef TFsPath path = TFsPath(char_path)
- self.assertEqual(path.IsDefined(), True)
- self.assertEquals(path.c_str(), "/a/b/c")
-
- def test_assignment(self):
- cdef TFsPath path1 = TFsPath("/a/b")
- cdef TFsPath path2 = TFsPath("/a/c")
-
- self.assertEquals(path1.GetPath(), "/a/b")
- self.assertEquals(path2.GetPath(), "/a/c")
-
- path2 = path1
-
- self.assertEquals(path1.GetPath(), "/a/b")
- self.assertEquals(path2.GetPath(), "/a/b")
-
- def test_check_defined(self):
- cdef TFsPath path1 = TFsPath()
- with self.assertRaises(RuntimeError):
- path1.CheckDefined()
- self.assertEqual(path1.IsDefined(), False)
- if path1:
- assert False
- else:
- pass
-
- cdef TFsPath path2 = TFsPath("")
- with self.assertRaises(RuntimeError):
- path2.CheckDefined()
- self.assertEqual(path2.IsDefined(), False)
- if path2:
- assert False
- else:
- pass
-
- cdef TFsPath path3 = TFsPath("/")
- path3.CheckDefined()
- self.assertEqual(path3.IsDefined(), True)
- if path3:
- pass
- else:
- assert False
-
- def test_comparison(self):
- cdef TFsPath path1 = TFsPath("/a/b")
- cdef TFsPath path2 = TFsPath("/a/c")
- cdef TFsPath path3 = TFsPath("/a/b")
-
- self.assertEqual(path1 == path3, True)
- self.assertEqual(path1 != path2, True)
- self.assertEqual(path3 != path2, True)
-
- def test_concatenation(self):
- cdef TFsPath path1 = TFsPath("/a")
- cdef TFsPath path2 = TFsPath("b")
- cdef TFsPath path3 = path1 / path2
- cdef TFsPath path4 = TFsPath("/a/b")
-
- self.assertEqual(path3 == path4, True)
-
- def test_fix(self):
- cdef TFsPath path = TFsPath("test_fix/b/c/../d")
- cdef TFsPath fixed = path.Fix()
- self.assertEquals(fixed.GetPath(), "test_fix/b/d")
-
- def test_parts(self):
- cdef TFsPath path = TFsPath("/a/b/c")
- self.assertEquals(path.GetPath(), "/a/b/c")
- self.assertEquals(path.GetName(), "c")
- self.assertEquals(path.GetExtension(), "")
- self.assertEquals(path.Basename(), "c")
- self.assertEquals(path.Dirname(), "/a/b")
-
- cdef TFsPath path_ext = TFsPath("/a/b/c.ext")
- self.assertEquals(path_ext.GetPath(), "/a/b/c.ext")
- self.assertEquals(path_ext.GetName(), "c.ext")
- self.assertEquals(path_ext.GetExtension(), "ext")
- self.assertEquals(path_ext.Basename(), "c.ext")
- self.assertEquals(path_ext.Dirname(), "/a/b")
-
- cdef TFsPath path_only_ext = TFsPath("/a/b/.ext")
- self.assertEquals(path_only_ext.GetPath(), "/a/b/.ext")
- self.assertEquals(path_only_ext.GetName(), ".ext")
- self.assertEquals(path_only_ext.GetExtension(), "")
- self.assertEquals(path_only_ext.Basename(), ".ext")
- self.assertEquals(path_only_ext.Dirname(), "/a/b")
-
- cdef TFsPath path_dir = TFsPath("/a/b/")
- self.assertEquals(path_dir.GetPath(), "/a/b/")
- self.assertEquals(path_dir.GetName(), "b")
- self.assertEquals(path_dir.GetExtension(), "")
- self.assertEquals(path_dir.Basename(), "b")
- self.assertEquals(path_dir.Dirname(), "/a")
-
- def test_absolute(self):
- cdef TFsPath path_absolute = TFsPath("/a/b/c")
- self.assertEquals(path_absolute.IsAbsolute(), True)
- self.assertEquals(path_absolute.IsRelative(), False)
-
- self.assertEquals(path_absolute.IsSubpathOf(TFsPath("/a/b")), True)
- self.assertEquals(path_absolute.IsNonStrictSubpathOf(TFsPath("/a/b")), True)
- self.assertEquals(TFsPath("/a/b").IsContainerOf(path_absolute), True)
-
- self.assertEquals(path_absolute.IsSubpathOf(TFsPath("/a/b/c")), False)
- self.assertEquals(path_absolute.IsNonStrictSubpathOf(TFsPath("/a/b/c")), True)
- self.assertEquals(TFsPath("/a/b/c").IsContainerOf(path_absolute), False)
-
- self.assertEquals(path_absolute.IsSubpathOf(TFsPath("/a/c")), False)
- self.assertEquals(path_absolute.IsNonStrictSubpathOf(TFsPath("/a/c")), False)
- self.assertEquals(TFsPath("/a/c").IsContainerOf(path_absolute), False)
-
- with self.assertRaises(RuntimeError):
- path_absolute.RelativeTo(TFsPath("/a/c"))
- self.assertEquals(path_absolute.RelativePath(TFsPath("/a/с")).GetPath(), "../b/c")
- self.assertEquals(path_absolute.RelativeTo(TFsPath("/a")).GetPath(), "b/c")
- self.assertEquals(path_absolute.RelativePath(TFsPath("/a")).GetPath(), "b/c")
- self.assertEquals(path_absolute.RelativeTo(TFsPath("/")).GetPath(), "a/b/c")
- self.assertEquals(path_absolute.RelativePath(TFsPath("/")).GetPath(), "a/b/c")
-
- with self.assertRaises(RuntimeError):
- path_absolute.RelativeTo(TFsPath("./a"))
- with self.assertRaises(RuntimeError):
- path_absolute.RelativePath(TFsPath("d"))
- self.assertEquals(path_absolute.RelativePath(TFsPath("./a")).GetPath(), "b/c")
-
- self.assertEquals(path_absolute.Parent().GetPath(), "/a/b")
- self.assertEquals(path_absolute.Child("d").GetPath(), "/a/b/c/d")
-
- def test_relative(self):
- cdef TFsPath path_relative_1 = TFsPath("a/b/c")
- self.assertEquals(path_relative_1.IsAbsolute(), False)
- self.assertEquals(path_relative_1.IsRelative(), True)
-
- self.assertEquals(path_relative_1.IsSubpathOf(TFsPath("a/b")), True)
- self.assertEquals(path_relative_1.IsNonStrictSubpathOf(TFsPath("a/b")), True)
- self.assertEquals(TFsPath("a/b").IsContainerOf(path_relative_1), True)
-
- self.assertEquals(path_relative_1.IsSubpathOf(TFsPath("a/b/c")), False)
- self.assertEquals(path_relative_1.IsNonStrictSubpathOf(TFsPath("a/b/c")), True)
- self.assertEquals(TFsPath("a/b/c").IsContainerOf(path_relative_1), False)
-
- self.assertEquals(path_relative_1.IsSubpathOf(TFsPath("a/c")), False)
- self.assertEquals(path_relative_1.IsNonStrictSubpathOf(TFsPath("a/c")), False)
- self.assertEquals(TFsPath("a/c").IsContainerOf(path_relative_1), False)
-
- self.assertEquals(path_relative_1.Parent().GetPath(), "a/b")
- self.assertEquals(path_relative_1.Child("d").GetPath(), "a/b/c/d")
-
- cdef TFsPath path_relative_2 = TFsPath("./a/b/c")
- self.assertEquals(path_relative_2.IsAbsolute(), False)
- self.assertEquals(path_relative_2.IsRelative(), True)
-
- self.assertEquals(path_relative_2.IsSubpathOf(TFsPath("a/b")), True)
- self.assertEquals(path_relative_2.IsNonStrictSubpathOf(TFsPath("a/b")), True)
- self.assertEquals(TFsPath("a/b").IsContainerOf(path_relative_2), True)
-
- self.assertEquals(path_relative_2.IsSubpathOf(TFsPath("a/b/c")), False)
- self.assertEquals(path_relative_2.IsNonStrictSubpathOf(TFsPath("a/b/c")), True)
- self.assertEquals(TFsPath("a/b/c").IsContainerOf(path_relative_2), False)
-
- self.assertEquals(path_relative_2.IsSubpathOf(TFsPath("a/c")), False)
- self.assertEquals(path_relative_2.IsNonStrictSubpathOf(TFsPath("a/c")), False)
- self.assertEquals(TFsPath("a/c").IsContainerOf(path_relative_2), False)
-
- with self.assertRaises(RuntimeError):
- path_relative_2.RelativeTo(TFsPath("a/c"))
- self.assertEquals(path_relative_2.RelativePath(TFsPath("a/с")).GetPath(), "../b/c")
- self.assertEquals(path_relative_2.RelativeTo(TFsPath("a")).GetPath(), "b/c")
- self.assertEquals(path_relative_2.RelativePath(TFsPath("a")).GetPath(), "b/c")
- self.assertEquals(path_relative_2.RelativeTo(TFsPath("./")).GetPath(), "a/b/c")
- self.assertEquals(path_relative_2.RelativePath(TFsPath("/a")).GetPath(), "b/c")
-
- with self.assertRaises(RuntimeError):
- self.assertEquals(path_relative_2.RelativePath(TFsPath("./")).GetPath(), "a/b/c")
-
- with self.assertRaises(RuntimeError):
- path_relative_2.RelativeTo(TFsPath("/d"))
- with self.assertRaises(RuntimeError):
- path_relative_2.RelativePath(TFsPath("/d"))
- with self.assertRaises(RuntimeError):
- path_relative_2.RelativePath(TFsPath("/"))
-
- self.assertEquals(path_relative_2.Parent().GetPath(), "a/b")
- self.assertEquals(path_relative_2.Child("d").GetPath(), "a/b/c/d")
-
- def test_mkdir(self):
- cdef TFsPath directory = TFsPath("test_mkdir")
- cdef TFsPath full = directory / directory
- cdef TFsPath internal = full / directory
- with self.assertRaises(RuntimeError):
- full.MkDir()
- full.MkDirs()
- internal.MkDir()
-
- def test_list(self):
- cdef TFsPath dir = TFsPath("test_list")
- dir.MkDir()
- TFsPath("test_list/b").Touch()
- TFsPath("test_list/c").Touch()
-
- cdef TVector[TFsPath] files
- cdef TVector[TString] names
-
- dir.List(files)
- dir.ListNames(names)
-
- self.assertEquals(files.size(), 2)
- self.assertEquals(sorted([files[0].GetPath(), files[1].GetPath()]), ["test_list/b", "test_list/c"])
- self.assertEquals(names.size(), 2)
- self.assertEquals(sorted(list(names)), ["b", "c"])
-
- def test_contains(self):
- cdef TFsPath path = TFsPath("a/b/c")
- self.assertEquals(path.Contains("c"), True)
- self.assertEquals(path.Contains("b"), True)
- self.assertEquals(path.Contains("d"), False)
-
- def test_delete(self):
- cdef TFsPath root = TFsPath("/")
- with self.assertRaises(RuntimeError):
- root.DeleteIfExists()
- with self.assertRaises(RuntimeError):
- root.ForceDelete()
-
- cdef TFsPath directory = TFsPath("test_delete")
- cdef TFsPath full = directory / directory
- full.MkDirs()
-
- self.assertEquals(full.Exists(), True)
- with self.assertRaises(RuntimeError):
- directory.DeleteIfExists()
- self.assertEquals(directory.Exists(), True)
- directory.ForceDelete()
- self.assertEquals(directory.Exists(), False)
-
- cdef TFsPath local_file = TFsPath("test_delete_1")
- self.assertEquals(local_file.Exists(), False)
- local_file.DeleteIfExists()
- self.assertEquals(local_file.Exists(), False)
- local_file.ForceDelete()
- self.assertEquals(local_file.Exists(), False)
-
- local_file.Touch()
- self.assertEquals(local_file.Exists(), True)
- local_file.DeleteIfExists()
- self.assertEquals(local_file.Exists(), False)
-
- local_file.Touch()
- self.assertEquals(local_file.Exists(), True)
- local_file.ForceDelete()
- self.assertEquals(local_file.Exists(), False)
-
- full.MkDirs()
- self.assertEquals(full.Exists(), True)
- full.DeleteIfExists()
- self.assertEquals(full.Exists(), False)
- self.assertEquals(directory.Exists(), True)
- directory.DeleteIfExists()
- self.assertEquals(directory.Exists(), False)
-
- def test_checks(self):
- cdef TFsPath local_file = TFsPath("test_checks")
- with self.assertRaises(RuntimeError):
- local_file.CheckExists()
- local_file.Touch()
- self.assertEquals(local_file.Exists(), True)
- self.assertEquals(local_file.IsDirectory(), False)
- self.assertEquals(local_file.IsFile(), True)
- self.assertEquals(local_file.IsSymlink(), False)
- local_file.CheckExists()
-
- local_file.DeleteIfExists()
- local_file.MkDir()
- self.assertEquals(local_file.Exists(), True)
- self.assertEquals(local_file.IsDirectory(), True)
- self.assertEquals(local_file.IsFile(), False)
- self.assertEquals(local_file.IsSymlink(), False)
- local_file.CheckExists()
-
- def test_rename(self):
- cdef TFsPath path = TFsPath("test_rename_a")
- path.Touch()
-
- cdef TString path_str = "test_rename_b"
- cdef TFsPath path_from_str = TFsPath(path_str)
- self.assertEquals(path.Exists(), True)
- self.assertEquals(path_from_str.Exists(), False)
- path.RenameTo(path_str)
- self.assertEquals(path.Exists(), False)
- self.assertEquals(path_from_str.Exists(), True)
-
- cdef const char* path_char = "test_rename_c"
- cdef TFsPath path_from_char = TFsPath(path_char)
- self.assertEquals(path_from_str.Exists(), True)
- self.assertEquals(path_from_char.Exists(), False)
- path_from_str.RenameTo(path_char)
- self.assertEquals(path_from_str.Exists(), False)
- self.assertEquals(path_from_char.Exists(), True)
-
- path_from_char.RenameTo(path)
-
- self.assertEquals(path_from_char.Exists(), False)
- self.assertEquals(path.Exists(), True)
-
- path.ForceRenameTo(path_str)
-
- self.assertEquals(path_from_str.Exists(), True)
- self.assertEquals(path.Exists(), False)
-
- with self.assertRaises(RuntimeError):
- path_from_str.RenameTo("")
-
- def test_copy(self):
- cdef TString dst = "test_copy_dst"
- cdef TFsPath src_path = TFsPath("test_copy_src")
- cdef TFsPath dst_path = TFsPath(dst)
- self.assertEquals(src_path.Exists(), False)
- src_path.Touch()
- self.assertEquals(src_path.Exists(), True)
- src_path.CopyTo(dst, False)
- self.assertEquals(src_path.Exists(), True)
- self.assertEquals(dst_path.Exists(), True)
-
- def test_real_path(self):
- cdef TFsPath path = TFsPath("test_real_path_a")
- path.Touch()
- self.assertEquals(path.RealPath().GetPath(), os.path.join(yatest.common.work_path(), "test_real_path_a"))
- self.assertEquals(path.RealLocation().GetPath(), os.path.join(yatest.common.work_path(), "test_real_path_a"))
- with self.assertRaises(RuntimeError):
- path.ReadLink()
-
- def test_cwd(self):
- cdef TFsPath path = TFsPath.Cwd()
- self.assertEquals(path.GetPath(), yatest.common.work_path())
-
- def test_swap(self):
- cdef TFsPath first = TFsPath("first")
- cdef TFsPath second = TFsPath("second")
-
- self.assertEquals(first.GetPath(), "first")
- self.assertEquals(second.GetPath(), "second")
- first.Swap(second)
- self.assertEquals(first.GetPath(), "second")
- self.assertEquals(second.GetPath(), "first")
- second.Swap(first)
- self.assertEquals(first.GetPath(), "first")
- self.assertEquals(second.GetPath(), "second")
+# cython: c_string_type=str, c_string_encoding=utf8
+
+from util.folder.path cimport TFsPath
+from util.generic.string cimport TString, TStringBuf
+from util.generic.vector cimport TVector
+
+import unittest
+import yatest.common
+
+import os.path
+
+
+class TestPath(unittest.TestCase):
+ def test_ctor1(self):
+ cdef TFsPath path = TFsPath()
+ self.assertEqual(path.IsDefined(), False)
+ self.assertEquals(path.c_str(), "")
+
+ def test_ctor2(self):
+ cdef TString str_path = "/a/b/c"
+ cdef TFsPath path = TFsPath(str_path)
+ self.assertEqual(path.IsDefined(), True)
+ self.assertEquals(path.c_str(), "/a/b/c")
+
+ def test_ctor3(self):
+ cdef TStringBuf buf_path = "/a/b/c"
+ cdef TFsPath path = TFsPath(buf_path)
+ self.assertEqual(path.IsDefined(), True)
+ self.assertEquals(path.c_str(), "/a/b/c")
+
+ def test_ctor4(self):
+ cdef char* char_path = "/a/b/c"
+ cdef TFsPath path = TFsPath(char_path)
+ self.assertEqual(path.IsDefined(), True)
+ self.assertEquals(path.c_str(), "/a/b/c")
+
+ def test_assignment(self):
+ cdef TFsPath path1 = TFsPath("/a/b")
+ cdef TFsPath path2 = TFsPath("/a/c")
+
+ self.assertEquals(path1.GetPath(), "/a/b")
+ self.assertEquals(path2.GetPath(), "/a/c")
+
+ path2 = path1
+
+ self.assertEquals(path1.GetPath(), "/a/b")
+ self.assertEquals(path2.GetPath(), "/a/b")
+
+ def test_check_defined(self):
+ cdef TFsPath path1 = TFsPath()
+ with self.assertRaises(RuntimeError):
+ path1.CheckDefined()
+ self.assertEqual(path1.IsDefined(), False)
+ if path1:
+ assert False
+ else:
+ pass
+
+ cdef TFsPath path2 = TFsPath("")
+ with self.assertRaises(RuntimeError):
+ path2.CheckDefined()
+ self.assertEqual(path2.IsDefined(), False)
+ if path2:
+ assert False
+ else:
+ pass
+
+ cdef TFsPath path3 = TFsPath("/")
+ path3.CheckDefined()
+ self.assertEqual(path3.IsDefined(), True)
+ if path3:
+ pass
+ else:
+ assert False
+
+ def test_comparison(self):
+ cdef TFsPath path1 = TFsPath("/a/b")
+ cdef TFsPath path2 = TFsPath("/a/c")
+ cdef TFsPath path3 = TFsPath("/a/b")
+
+ self.assertEqual(path1 == path3, True)
+ self.assertEqual(path1 != path2, True)
+ self.assertEqual(path3 != path2, True)
+
+ def test_concatenation(self):
+ cdef TFsPath path1 = TFsPath("/a")
+ cdef TFsPath path2 = TFsPath("b")
+ cdef TFsPath path3 = path1 / path2
+ cdef TFsPath path4 = TFsPath("/a/b")
+
+ self.assertEqual(path3 == path4, True)
+
+ def test_fix(self):
+ cdef TFsPath path = TFsPath("test_fix/b/c/../d")
+ cdef TFsPath fixed = path.Fix()
+ self.assertEquals(fixed.GetPath(), "test_fix/b/d")
+
+ def test_parts(self):
+ cdef TFsPath path = TFsPath("/a/b/c")
+ self.assertEquals(path.GetPath(), "/a/b/c")
+ self.assertEquals(path.GetName(), "c")
+ self.assertEquals(path.GetExtension(), "")
+ self.assertEquals(path.Basename(), "c")
+ self.assertEquals(path.Dirname(), "/a/b")
+
+ cdef TFsPath path_ext = TFsPath("/a/b/c.ext")
+ self.assertEquals(path_ext.GetPath(), "/a/b/c.ext")
+ self.assertEquals(path_ext.GetName(), "c.ext")
+ self.assertEquals(path_ext.GetExtension(), "ext")
+ self.assertEquals(path_ext.Basename(), "c.ext")
+ self.assertEquals(path_ext.Dirname(), "/a/b")
+
+ cdef TFsPath path_only_ext = TFsPath("/a/b/.ext")
+ self.assertEquals(path_only_ext.GetPath(), "/a/b/.ext")
+ self.assertEquals(path_only_ext.GetName(), ".ext")
+ self.assertEquals(path_only_ext.GetExtension(), "")
+ self.assertEquals(path_only_ext.Basename(), ".ext")
+ self.assertEquals(path_only_ext.Dirname(), "/a/b")
+
+ cdef TFsPath path_dir = TFsPath("/a/b/")
+ self.assertEquals(path_dir.GetPath(), "/a/b/")
+ self.assertEquals(path_dir.GetName(), "b")
+ self.assertEquals(path_dir.GetExtension(), "")
+ self.assertEquals(path_dir.Basename(), "b")
+ self.assertEquals(path_dir.Dirname(), "/a")
+
+ def test_absolute(self):
+ cdef TFsPath path_absolute = TFsPath("/a/b/c")
+ self.assertEquals(path_absolute.IsAbsolute(), True)
+ self.assertEquals(path_absolute.IsRelative(), False)
+
+ self.assertEquals(path_absolute.IsSubpathOf(TFsPath("/a/b")), True)
+ self.assertEquals(path_absolute.IsNonStrictSubpathOf(TFsPath("/a/b")), True)
+ self.assertEquals(TFsPath("/a/b").IsContainerOf(path_absolute), True)
+
+ self.assertEquals(path_absolute.IsSubpathOf(TFsPath("/a/b/c")), False)
+ self.assertEquals(path_absolute.IsNonStrictSubpathOf(TFsPath("/a/b/c")), True)
+ self.assertEquals(TFsPath("/a/b/c").IsContainerOf(path_absolute), False)
+
+ self.assertEquals(path_absolute.IsSubpathOf(TFsPath("/a/c")), False)
+ self.assertEquals(path_absolute.IsNonStrictSubpathOf(TFsPath("/a/c")), False)
+ self.assertEquals(TFsPath("/a/c").IsContainerOf(path_absolute), False)
+
+ with self.assertRaises(RuntimeError):
+ path_absolute.RelativeTo(TFsPath("/a/c"))
+ self.assertEquals(path_absolute.RelativePath(TFsPath("/a/с")).GetPath(), "../b/c")
+ self.assertEquals(path_absolute.RelativeTo(TFsPath("/a")).GetPath(), "b/c")
+ self.assertEquals(path_absolute.RelativePath(TFsPath("/a")).GetPath(), "b/c")
+ self.assertEquals(path_absolute.RelativeTo(TFsPath("/")).GetPath(), "a/b/c")
+ self.assertEquals(path_absolute.RelativePath(TFsPath("/")).GetPath(), "a/b/c")
+
+ with self.assertRaises(RuntimeError):
+ path_absolute.RelativeTo(TFsPath("./a"))
+ with self.assertRaises(RuntimeError):
+ path_absolute.RelativePath(TFsPath("d"))
+ self.assertEquals(path_absolute.RelativePath(TFsPath("./a")).GetPath(), "b/c")
+
+ self.assertEquals(path_absolute.Parent().GetPath(), "/a/b")
+ self.assertEquals(path_absolute.Child("d").GetPath(), "/a/b/c/d")
+
+ def test_relative(self):
+ cdef TFsPath path_relative_1 = TFsPath("a/b/c")
+ self.assertEquals(path_relative_1.IsAbsolute(), False)
+ self.assertEquals(path_relative_1.IsRelative(), True)
+
+ self.assertEquals(path_relative_1.IsSubpathOf(TFsPath("a/b")), True)
+ self.assertEquals(path_relative_1.IsNonStrictSubpathOf(TFsPath("a/b")), True)
+ self.assertEquals(TFsPath("a/b").IsContainerOf(path_relative_1), True)
+
+ self.assertEquals(path_relative_1.IsSubpathOf(TFsPath("a/b/c")), False)
+ self.assertEquals(path_relative_1.IsNonStrictSubpathOf(TFsPath("a/b/c")), True)
+ self.assertEquals(TFsPath("a/b/c").IsContainerOf(path_relative_1), False)
+
+ self.assertEquals(path_relative_1.IsSubpathOf(TFsPath("a/c")), False)
+ self.assertEquals(path_relative_1.IsNonStrictSubpathOf(TFsPath("a/c")), False)
+ self.assertEquals(TFsPath("a/c").IsContainerOf(path_relative_1), False)
+
+ self.assertEquals(path_relative_1.Parent().GetPath(), "a/b")
+ self.assertEquals(path_relative_1.Child("d").GetPath(), "a/b/c/d")
+
+ cdef TFsPath path_relative_2 = TFsPath("./a/b/c")
+ self.assertEquals(path_relative_2.IsAbsolute(), False)
+ self.assertEquals(path_relative_2.IsRelative(), True)
+
+ self.assertEquals(path_relative_2.IsSubpathOf(TFsPath("a/b")), True)
+ self.assertEquals(path_relative_2.IsNonStrictSubpathOf(TFsPath("a/b")), True)
+ self.assertEquals(TFsPath("a/b").IsContainerOf(path_relative_2), True)
+
+ self.assertEquals(path_relative_2.IsSubpathOf(TFsPath("a/b/c")), False)
+ self.assertEquals(path_relative_2.IsNonStrictSubpathOf(TFsPath("a/b/c")), True)
+ self.assertEquals(TFsPath("a/b/c").IsContainerOf(path_relative_2), False)
+
+ self.assertEquals(path_relative_2.IsSubpathOf(TFsPath("a/c")), False)
+ self.assertEquals(path_relative_2.IsNonStrictSubpathOf(TFsPath("a/c")), False)
+ self.assertEquals(TFsPath("a/c").IsContainerOf(path_relative_2), False)
+
+ with self.assertRaises(RuntimeError):
+ path_relative_2.RelativeTo(TFsPath("a/c"))
+ self.assertEquals(path_relative_2.RelativePath(TFsPath("a/с")).GetPath(), "../b/c")
+ self.assertEquals(path_relative_2.RelativeTo(TFsPath("a")).GetPath(), "b/c")
+ self.assertEquals(path_relative_2.RelativePath(TFsPath("a")).GetPath(), "b/c")
+ self.assertEquals(path_relative_2.RelativeTo(TFsPath("./")).GetPath(), "a/b/c")
+ self.assertEquals(path_relative_2.RelativePath(TFsPath("/a")).GetPath(), "b/c")
+
+ with self.assertRaises(RuntimeError):
+ self.assertEquals(path_relative_2.RelativePath(TFsPath("./")).GetPath(), "a/b/c")
+
+ with self.assertRaises(RuntimeError):
+ path_relative_2.RelativeTo(TFsPath("/d"))
+ with self.assertRaises(RuntimeError):
+ path_relative_2.RelativePath(TFsPath("/d"))
+ with self.assertRaises(RuntimeError):
+ path_relative_2.RelativePath(TFsPath("/"))
+
+ self.assertEquals(path_relative_2.Parent().GetPath(), "a/b")
+ self.assertEquals(path_relative_2.Child("d").GetPath(), "a/b/c/d")
+
+ def test_mkdir(self):
+ cdef TFsPath directory = TFsPath("test_mkdir")
+ cdef TFsPath full = directory / directory
+ cdef TFsPath internal = full / directory
+ with self.assertRaises(RuntimeError):
+ full.MkDir()
+ full.MkDirs()
+ internal.MkDir()
+
+ def test_list(self):
+ cdef TFsPath dir = TFsPath("test_list")
+ dir.MkDir()
+ TFsPath("test_list/b").Touch()
+ TFsPath("test_list/c").Touch()
+
+ cdef TVector[TFsPath] files
+ cdef TVector[TString] names
+
+ dir.List(files)
+ dir.ListNames(names)
+
+ self.assertEquals(files.size(), 2)
+ self.assertEquals(sorted([files[0].GetPath(), files[1].GetPath()]), ["test_list/b", "test_list/c"])
+ self.assertEquals(names.size(), 2)
+ self.assertEquals(sorted(list(names)), ["b", "c"])
+
+ def test_contains(self):
+ cdef TFsPath path = TFsPath("a/b/c")
+ self.assertEquals(path.Contains("c"), True)
+ self.assertEquals(path.Contains("b"), True)
+ self.assertEquals(path.Contains("d"), False)
+
+ def test_delete(self):
+ cdef TFsPath root = TFsPath("/")
+ with self.assertRaises(RuntimeError):
+ root.DeleteIfExists()
+ with self.assertRaises(RuntimeError):
+ root.ForceDelete()
+
+ cdef TFsPath directory = TFsPath("test_delete")
+ cdef TFsPath full = directory / directory
+ full.MkDirs()
+
+ self.assertEquals(full.Exists(), True)
+ with self.assertRaises(RuntimeError):
+ directory.DeleteIfExists()
+ self.assertEquals(directory.Exists(), True)
+ directory.ForceDelete()
+ self.assertEquals(directory.Exists(), False)
+
+ cdef TFsPath local_file = TFsPath("test_delete_1")
+ self.assertEquals(local_file.Exists(), False)
+ local_file.DeleteIfExists()
+ self.assertEquals(local_file.Exists(), False)
+ local_file.ForceDelete()
+ self.assertEquals(local_file.Exists(), False)
+
+ local_file.Touch()
+ self.assertEquals(local_file.Exists(), True)
+ local_file.DeleteIfExists()
+ self.assertEquals(local_file.Exists(), False)
+
+ local_file.Touch()
+ self.assertEquals(local_file.Exists(), True)
+ local_file.ForceDelete()
+ self.assertEquals(local_file.Exists(), False)
+
+ full.MkDirs()
+ self.assertEquals(full.Exists(), True)
+ full.DeleteIfExists()
+ self.assertEquals(full.Exists(), False)
+ self.assertEquals(directory.Exists(), True)
+ directory.DeleteIfExists()
+ self.assertEquals(directory.Exists(), False)
+
+ def test_checks(self):
+ cdef TFsPath local_file = TFsPath("test_checks")
+ with self.assertRaises(RuntimeError):
+ local_file.CheckExists()
+ local_file.Touch()
+ self.assertEquals(local_file.Exists(), True)
+ self.assertEquals(local_file.IsDirectory(), False)
+ self.assertEquals(local_file.IsFile(), True)
+ self.assertEquals(local_file.IsSymlink(), False)
+ local_file.CheckExists()
+
+ local_file.DeleteIfExists()
+ local_file.MkDir()
+ self.assertEquals(local_file.Exists(), True)
+ self.assertEquals(local_file.IsDirectory(), True)
+ self.assertEquals(local_file.IsFile(), False)
+ self.assertEquals(local_file.IsSymlink(), False)
+ local_file.CheckExists()
+
+ def test_rename(self):
+ cdef TFsPath path = TFsPath("test_rename_a")
+ path.Touch()
+
+ cdef TString path_str = "test_rename_b"
+ cdef TFsPath path_from_str = TFsPath(path_str)
+ self.assertEquals(path.Exists(), True)
+ self.assertEquals(path_from_str.Exists(), False)
+ path.RenameTo(path_str)
+ self.assertEquals(path.Exists(), False)
+ self.assertEquals(path_from_str.Exists(), True)
+
+ cdef const char* path_char = "test_rename_c"
+ cdef TFsPath path_from_char = TFsPath(path_char)
+ self.assertEquals(path_from_str.Exists(), True)
+ self.assertEquals(path_from_char.Exists(), False)
+ path_from_str.RenameTo(path_char)
+ self.assertEquals(path_from_str.Exists(), False)
+ self.assertEquals(path_from_char.Exists(), True)
+
+ path_from_char.RenameTo(path)
+
+ self.assertEquals(path_from_char.Exists(), False)
+ self.assertEquals(path.Exists(), True)
+
+ path.ForceRenameTo(path_str)
+
+ self.assertEquals(path_from_str.Exists(), True)
+ self.assertEquals(path.Exists(), False)
+
+ with self.assertRaises(RuntimeError):
+ path_from_str.RenameTo("")
+
+ def test_copy(self):
+ cdef TString dst = "test_copy_dst"
+ cdef TFsPath src_path = TFsPath("test_copy_src")
+ cdef TFsPath dst_path = TFsPath(dst)
+ self.assertEquals(src_path.Exists(), False)
+ src_path.Touch()
+ self.assertEquals(src_path.Exists(), True)
+ src_path.CopyTo(dst, False)
+ self.assertEquals(src_path.Exists(), True)
+ self.assertEquals(dst_path.Exists(), True)
+
+ def test_real_path(self):
+ cdef TFsPath path = TFsPath("test_real_path_a")
+ path.Touch()
+ self.assertEquals(path.RealPath().GetPath(), os.path.join(yatest.common.work_path(), "test_real_path_a"))
+ self.assertEquals(path.RealLocation().GetPath(), os.path.join(yatest.common.work_path(), "test_real_path_a"))
+ with self.assertRaises(RuntimeError):
+ path.ReadLink()
+
+ def test_cwd(self):
+ cdef TFsPath path = TFsPath.Cwd()
+ self.assertEquals(path.GetPath(), yatest.common.work_path())
+
+ def test_swap(self):
+ cdef TFsPath first = TFsPath("first")
+ cdef TFsPath second = TFsPath("second")
+
+ self.assertEquals(first.GetPath(), "first")
+ self.assertEquals(second.GetPath(), "second")
+ first.Swap(second)
+ self.assertEquals(first.GetPath(), "second")
+ self.assertEquals(second.GetPath(), "first")
+ second.Swap(first)
+ self.assertEquals(first.GetPath(), "first")
+ self.assertEquals(second.GetPath(), "second")
diff --git a/util/generic/deque.pxd b/util/generic/deque.pxd
index ae3b31fb5f..62834ac2ad 100644
--- a/util/generic/deque.pxd
+++ b/util/generic/deque.pxd
@@ -1,9 +1,9 @@
-from libcpp.deque cimport deque
-
-
-cdef extern from "<util/generic/deque.h>" nogil:
- cdef cppclass TDeque[T](deque):
- TDeque() except +
- TDeque(size_t) except +
- TDeque(size_t, const T&) except +
- TDeque(const TDeque&) except +
+from libcpp.deque cimport deque
+
+
+cdef extern from "<util/generic/deque.h>" nogil:
+ cdef cppclass TDeque[T](deque):
+ TDeque() except +
+ TDeque(size_t) except +
+ TDeque(size_t, const T&) except +
+ TDeque(const TDeque&) except +
diff --git a/util/generic/deque_ut.pyx b/util/generic/deque_ut.pyx
index 5c8e985d8b..42cec42647 100644
--- a/util/generic/deque_ut.pyx
+++ b/util/generic/deque_ut.pyx
@@ -1,66 +1,66 @@
-from libcpp.deque cimport deque
-from util.generic.deque cimport TDeque
-
-import pytest
-import unittest
-
-
-class TestDeque(unittest.TestCase):
- def test_ctor1(self):
- cdef TDeque[int] tmp = TDeque[int]()
- self.assertEqual(tmp.size(), 0)
-
- def test_ctor2(self):
- cdef TDeque[int] tmp = TDeque[int](10)
- self.assertEqual(tmp.size(), 10)
- self.assertEqual(tmp[0], 0)
-
- def test_ctor3(self):
- cdef TDeque[int] tmp = TDeque[int](10, 42)
- self.assertEqual(tmp.size(), 10)
- self.assertEqual(tmp[0], 42)
-
- def test_ctor4(self):
- cdef TDeque[int] tmp = TDeque[int](10, 42)
- cdef TDeque[int] tmp2 = TDeque[int](tmp)
- self.assertEqual(tmp2.size(), 10)
- self.assertEqual(tmp2[0], 42)
-
- def test_operator_assign(self):
- cdef TDeque[int] tmp2
- tmp2.push_back(1)
- tmp2.push_back(2)
-
- cdef TDeque[int] tmp3
- tmp3.push_back(1)
- tmp3.push_back(3)
-
- self.assertEqual(tmp2[1], 2)
- self.assertEqual(tmp3[1], 3)
-
- tmp3 = tmp2
-
- self.assertEqual(tmp2[1], 2)
- self.assertEqual(tmp3[1], 2)
-
- def test_compare(self):
- cdef TDeque[int] tmp1
- tmp1.push_back(1)
- tmp1.push_back(2)
-
- cdef TDeque[int] tmp2
- tmp2.push_back(1)
- tmp2.push_back(2)
-
- cdef TDeque[int] tmp3
- tmp3.push_back(1)
- tmp3.push_back(3)
-
- self.assertTrue(tmp1 == tmp2)
- self.assertTrue(tmp1 != tmp3)
-
- self.assertTrue(tmp1 < tmp3)
- self.assertTrue(tmp1 <= tmp3)
-
- self.assertTrue(tmp3 > tmp1)
- self.assertTrue(tmp3 >= tmp1) \ No newline at end of file
+from libcpp.deque cimport deque
+from util.generic.deque cimport TDeque
+
+import pytest
+import unittest
+
+
+class TestDeque(unittest.TestCase):
+ def test_ctor1(self):
+ cdef TDeque[int] tmp = TDeque[int]()
+ self.assertEqual(tmp.size(), 0)
+
+ def test_ctor2(self):
+ cdef TDeque[int] tmp = TDeque[int](10)
+ self.assertEqual(tmp.size(), 10)
+ self.assertEqual(tmp[0], 0)
+
+ def test_ctor3(self):
+ cdef TDeque[int] tmp = TDeque[int](10, 42)
+ self.assertEqual(tmp.size(), 10)
+ self.assertEqual(tmp[0], 42)
+
+ def test_ctor4(self):
+ cdef TDeque[int] tmp = TDeque[int](10, 42)
+ cdef TDeque[int] tmp2 = TDeque[int](tmp)
+ self.assertEqual(tmp2.size(), 10)
+ self.assertEqual(tmp2[0], 42)
+
+ def test_operator_assign(self):
+ cdef TDeque[int] tmp2
+ tmp2.push_back(1)
+ tmp2.push_back(2)
+
+ cdef TDeque[int] tmp3
+ tmp3.push_back(1)
+ tmp3.push_back(3)
+
+ self.assertEqual(tmp2[1], 2)
+ self.assertEqual(tmp3[1], 3)
+
+ tmp3 = tmp2
+
+ self.assertEqual(tmp2[1], 2)
+ self.assertEqual(tmp3[1], 2)
+
+ def test_compare(self):
+ cdef TDeque[int] tmp1
+ tmp1.push_back(1)
+ tmp1.push_back(2)
+
+ cdef TDeque[int] tmp2
+ tmp2.push_back(1)
+ tmp2.push_back(2)
+
+ cdef TDeque[int] tmp3
+ tmp3.push_back(1)
+ tmp3.push_back(3)
+
+ self.assertTrue(tmp1 == tmp2)
+ self.assertTrue(tmp1 != tmp3)
+
+ self.assertTrue(tmp1 < tmp3)
+ self.assertTrue(tmp1 <= tmp3)
+
+ self.assertTrue(tmp3 > tmp1)
+ self.assertTrue(tmp3 >= tmp1) \ No newline at end of file
diff --git a/util/generic/hash.pxd b/util/generic/hash.pxd
index 1eabe0e380..385c10d805 100644
--- a/util/generic/hash.pxd
+++ b/util/generic/hash.pxd
@@ -12,16 +12,16 @@ cdef extern from "util/generic/hash.h" nogil:
cppclass const_iterator(iterator):
pass
- cppclass reverse_iterator:
- pair[T, U]& operator*()
- iterator operator++()
- iterator operator--()
- bint operator==(reverse_iterator)
- bint operator!=(reverse_iterator)
-
- cppclass const_reverse_iterator(reverse_iterator):
- pass
-
+ cppclass reverse_iterator:
+ pair[T, U]& operator*()
+ iterator operator++()
+ iterator operator--()
+ bint operator==(reverse_iterator)
+ bint operator!=(reverse_iterator)
+
+ cppclass const_reverse_iterator(reverse_iterator):
+ pass
+
THashMap() except +
THashMap(THashMap&) except +
U& operator[](T&)
@@ -54,13 +54,13 @@ cdef extern from "util/generic/hash.h" nogil:
size_t max_size()
size_t size()
void swap(THashMap&)
- iterator lower_bound(T&)
- const_iterator const_lower_bound "lower_bound"(T&)
- reverse_iterator rbegin()
- const_reverse_iterator const_rbegin "rbegin"()
- reverse_iterator rend()
- const_reverse_iterator const_rend "rend"()
- iterator upper_bound(T&)
- const_iterator const_upper_bound "upper_bound"(T&)
- void max_load_factor(float)
- float max_load_factor()
+ iterator lower_bound(T&)
+ const_iterator const_lower_bound "lower_bound"(T&)
+ reverse_iterator rbegin()
+ const_reverse_iterator const_rbegin "rbegin"()
+ reverse_iterator rend()
+ const_reverse_iterator const_rend "rend"()
+ iterator upper_bound(T&)
+ const_iterator const_upper_bound "upper_bound"(T&)
+ void max_load_factor(float)
+ float max_load_factor()
diff --git a/util/generic/hash_set_ut.pyx b/util/generic/hash_set_ut.pyx
index 275ffddd3f..bdcf6284af 100644
--- a/util/generic/hash_set_ut.pyx
+++ b/util/generic/hash_set_ut.pyx
@@ -9,7 +9,7 @@ import unittest
from cython.operator cimport dereference as deref
-class TestHashSet(unittest.TestCase):
+class TestHashSet(unittest.TestCase):
def test_simple_constructor_equality_operator(self):
cdef THashSet[int] c1
diff --git a/util/generic/hash_ut.pyx b/util/generic/hash_ut.pyx
index d714288da1..ecf6dac2e6 100644
--- a/util/generic/hash_ut.pyx
+++ b/util/generic/hash_ut.pyx
@@ -1,5 +1,5 @@
-# cython: c_string_type=str, c_string_encoding=utf8
-
+# cython: c_string_type=str, c_string_encoding=utf8
+
from util.generic.hash cimport THashMap
from util.generic.string cimport TString
diff --git a/util/generic/ptr.pxd b/util/generic/ptr.pxd
index 7eb3171aab..16e8d19144 100644
--- a/util/generic/ptr.pxd
+++ b/util/generic/ptr.pxd
@@ -8,10 +8,10 @@ cdef extern from "<util/generic/ptr.h>" nogil:
void Reset(T*)
void Swap(THolder[T])
-
+
cdef THolder[T] MakeHolder[T](...)
-
+
cdef cppclass TIntrusivePtr[T]:
TIntrusivePtr()
TIntrusivePtr(T*)
@@ -21,16 +21,16 @@ cdef extern from "<util/generic/ptr.h>" nogil:
T* Release()
void Drop()
-
- cdef cppclass TIntrusiveConstPtr[T]:
- TIntrusiveConstPtr()
- TIntrusiveConstPtr(T*)
- TIntrusiveConstPtr& operator=(...)
- void Reset(T*)
- const T* Get()
- void Drop()
-
-
+
+ cdef cppclass TIntrusiveConstPtr[T]:
+ TIntrusiveConstPtr()
+ TIntrusiveConstPtr(T*)
+ TIntrusiveConstPtr& operator=(...)
+ void Reset(T*)
+ const T* Get()
+ void Drop()
+
+
cdef cppclass TAtomicSharedPtr[T]:
TAtomicSharedPtr()
TAtomicSharedPtr(T*)
diff --git a/util/generic/string.pxd b/util/generic/string.pxd
index 2ae1555c21..c25f7392a1 100644
--- a/util/generic/string.pxd
+++ b/util/generic/string.pxd
@@ -6,9 +6,9 @@ cdef extern from "<util/generic/strbuf.h>" nogil:
TStringBuf() except +
TStringBuf(const char*) except +
TStringBuf(const char*, size_t) except +
- const char* data()
+ const char* data()
char* Data()
- size_t size()
+ size_t size()
size_t Size()
diff --git a/util/generic/string_ut.pyx b/util/generic/string_ut.pyx
index c7428f857a..5407f5b4c1 100644
--- a/util/generic/string_ut.pyx
+++ b/util/generic/string_ut.pyx
@@ -1,14 +1,14 @@
-# cython: c_string_type=str, c_string_encoding=utf8
-
+# cython: c_string_type=str, c_string_encoding=utf8
+
from libcpp.string cimport string as std_string
from util.generic.string cimport TString, npos
import pytest
import unittest
-import sys
+import sys
+
-
class TestStroka(unittest.TestCase):
def test_unicode(self):
cdef TString x = "привет"
@@ -18,38 +18,38 @@ class TestStroka(unittest.TestCase):
def test_ctor1(self):
cdef TString tmp = TString()
cdef TString tmp2 = TString(tmp)
- self.assertEquals(tmp2, "")
+ self.assertEquals(tmp2, "")
def test_ctor2(self):
cdef std_string tmp = b"hello"
cdef TString tmp2 = TString(tmp)
- self.assertEquals(tmp2, "hello")
+ self.assertEquals(tmp2, "hello")
def test_ctor3(self):
cdef TString tmp = b"hello"
cdef TString tmp2 = TString(tmp, 0, 4)
- self.assertEquals(tmp2, "hell")
+ self.assertEquals(tmp2, "hell")
def test_ctor4(self):
cdef TString tmp = TString(<char*>b"hello")
- self.assertEquals(tmp, "hello")
+ self.assertEquals(tmp, "hello")
def test_ctor5(self):
cdef TString tmp = TString(<char*>b"hello", 4)
- self.assertEquals(tmp, "hell")
+ self.assertEquals(tmp, "hell")
def test_ctor6(self):
cdef TString tmp = TString(<char*>b"hello", 1, 3)
- self.assertEquals(tmp, "ell")
+ self.assertEquals(tmp, "ell")
def test_ctor7(self):
cdef TString tmp = TString(3, <char>'x')
- self.assertEquals(tmp, "xxx")
+ self.assertEquals(tmp, "xxx")
def test_ctor8(self):
cdef bytes tmp = b"hello"
cdef TString tmp2 = TString(<char*>tmp, <char*>tmp + 4)
- self.assertEquals(tmp2, "hell")
+ self.assertEquals(tmp2, "hell")
def test_compare(self):
cdef TString tmp1 = b"abacab"
@@ -72,18 +72,18 @@ class TestStroka(unittest.TestCase):
def test_operator_assign(self):
cdef TString tmp = b"hello"
cdef TString tmp2 = tmp
- self.assertEquals(tmp2, "hello")
+ self.assertEquals(tmp2, "hello")
def test_operator_plus(self):
cdef TString tmp = TString(b"hello ") + TString(b"world")
- self.assertEquals(tmp, "hello world")
+ self.assertEquals(tmp, "hello world")
def test_c_str(self):
cdef TString tmp = b"hello"
- if sys.version_info.major == 2:
- self.assertEquals(bytes(tmp.c_str()), b"hello")
- else:
- self.assertEquals(bytes(tmp.c_str(), 'utf8'), b"hello")
+ if sys.version_info.major == 2:
+ self.assertEquals(bytes(tmp.c_str()), b"hello")
+ else:
+ self.assertEquals(bytes(tmp.c_str(), 'utf8'), b"hello")
def test_length(self):
cdef TString tmp = b"hello"
@@ -107,70 +107,70 @@ class TestStroka(unittest.TestCase):
cdef TString tmp2 = b"fuu"
tmp.append(tmp2)
- self.assertEquals(tmp, "fuu")
+ self.assertEquals(tmp, "fuu")
tmp.append(tmp2, 1, 2)
- self.assertEquals(tmp, "fuuuu")
+ self.assertEquals(tmp, "fuuuu")
tmp.append(<char*>"ll ")
- self.assertEquals(tmp, "fuuuull ")
+ self.assertEquals(tmp, "fuuuull ")
tmp.append(<char*>"of greatness", 4)
- self.assertEquals(tmp, "fuuuull of g")
+ self.assertEquals(tmp, "fuuuull of g")
tmp.append(2, <char>b'o')
- self.assertEquals(tmp, "fuuuull of goo")
+ self.assertEquals(tmp, "fuuuull of goo")
tmp.push_back(b'z')
- self.assertEquals(tmp, "fuuuull of gooz")
+ self.assertEquals(tmp, "fuuuull of gooz")
def test_assign(self):
cdef TString tmp
tmp.assign(b"one")
- self.assertEquals(tmp, "one")
+ self.assertEquals(tmp, "one")
tmp.assign(b"two hundred", 0, 3)
- self.assertEquals(tmp, "two")
+ self.assertEquals(tmp, "two")
tmp.assign(<char*>b"three")
- self.assertEquals(tmp, "three")
+ self.assertEquals(tmp, "three")
tmp.assign(<char*>b"three fiddy", 5)
- self.assertEquals(tmp, "three")
+ self.assertEquals(tmp, "three")
def test_insert(self):
cdef TString tmp
tmp = b"xx"
tmp.insert(1, b"foo")
- self.assertEquals(tmp, "xfoox")
+ self.assertEquals(tmp, "xfoox")
tmp = b"xx"
tmp.insert(1, b"haxor", 1, 3)
- self.assertEquals(tmp, "xaxox")
+ self.assertEquals(tmp, "xaxox")
tmp = b"xx"
tmp.insert(1, <char*>b"foo")
- self.assertEquals(tmp, "xfoox")
+ self.assertEquals(tmp, "xfoox")
tmp = b"xx"
tmp.insert(1, <char*>b"foozzy", 3)
- self.assertEquals(tmp, "xfoox")
+ self.assertEquals(tmp, "xfoox")
tmp = b"xx"
tmp.insert(1, 2, <char>b'u')
- self.assertEquals(tmp, "xuux")
+ self.assertEquals(tmp, "xuux")
def test_copy(self):
cdef char buf[16]
cdef TString tmp = b"hello"
tmp.copy(buf, 5, 0)
- self.assertEquals(buf[:5], "hello")
+ self.assertEquals(buf[:5], "hello")
def test_find(self):
cdef TString haystack = b"whole lotta bytes"
- cdef TString needle = "hole"
+ cdef TString needle = "hole"
self.assertEquals(haystack.find(needle), 1)
self.assertEquals(haystack.find(needle, 3), npos)
@@ -221,5 +221,5 @@ class TestStroka(unittest.TestCase):
def test_substr(self):
cdef TString tmp = b"foobar"
- self.assertEquals(tmp.substr(1), "oobar")
- self.assertEquals(tmp.substr(1, 4), "ooba")
+ self.assertEquals(tmp.substr(1), "oobar")
+ self.assertEquals(tmp.substr(1, 4), "ooba")
diff --git a/util/generic/vector_ut.pyx b/util/generic/vector_ut.pyx
index 8bdcf7d16e..904e67733b 100644
--- a/util/generic/vector_ut.pyx
+++ b/util/generic/vector_ut.pyx
@@ -1,5 +1,5 @@
-# cython: c_string_type=str, c_string_encoding=utf8
-
+# cython: c_string_type=str, c_string_encoding=utf8
+
from util.generic.vector cimport TVector
from util.generic.string cimport TString
@@ -42,14 +42,14 @@ class TestVector(unittest.TestCase):
tmp3.push_back(1)
tmp3.push_back(3)
- self.assertEqual(tmp2[1], 2)
- self.assertEqual(tmp3[1], 3)
-
+ self.assertEqual(tmp2[1], 2)
+ self.assertEqual(tmp3[1], 3)
+
tmp3 = tmp2
- self.assertEqual(tmp2[1], 2)
- self.assertEqual(tmp3[1], 2)
-
+ self.assertEqual(tmp2[1], 2)
+ self.assertEqual(tmp3[1], 2)
+
def test_compare(self):
cdef TVector[int] tmp1
tmp1.push_back(1)
diff --git a/util/memory/blob.pxd b/util/memory/blob.pxd
index d71591a198..c68525024a 100644
--- a/util/memory/blob.pxd
+++ b/util/memory/blob.pxd
@@ -1,41 +1,41 @@
-from libcpp cimport bool as bool_t
-
-from util.generic.string cimport TString
-from util.system.types cimport ui8
-
-
-cdef extern from "util/memory/blob.h" nogil:
- cdef cppclass TBlob:
- TBlob()
- TBlob(const TBlob&)
- void Swap(TBlob& r)
- const void* Data() const
- size_t Size() const
- bool_t Empty() const
- bool_t IsNull() const
- const char* AsCharPtr() const
- const unsigned char* AsUnsignedCharPtr() const
- void Drop()
- TBlob SubBlob(size_t len) except +
- TBlob SubBlob(size_t begin, size_t end) except +
- TBlob DeepCopy() except +
-
- @staticmethod
- TBlob NoCopy(const void* data, size_t length) except +
-
- @staticmethod
- TBlob Copy(const void* data, size_t length) except +
-
- @staticmethod
- TBlob FromFile(const TString& path) except +
-
- @staticmethod
- TBlob PrechargedFromFile(const TString& path) except +
-
- @staticmethod
- TBlob FromString(const TString& s) except +
-
- ui8& operator[](size_t) const
- TBlob& operator=(TBlob&)
-
-
+from libcpp cimport bool as bool_t
+
+from util.generic.string cimport TString
+from util.system.types cimport ui8
+
+
+cdef extern from "util/memory/blob.h" nogil:
+ cdef cppclass TBlob:
+ TBlob()
+ TBlob(const TBlob&)
+ void Swap(TBlob& r)
+ const void* Data() const
+ size_t Size() const
+ bool_t Empty() const
+ bool_t IsNull() const
+ const char* AsCharPtr() const
+ const unsigned char* AsUnsignedCharPtr() const
+ void Drop()
+ TBlob SubBlob(size_t len) except +
+ TBlob SubBlob(size_t begin, size_t end) except +
+ TBlob DeepCopy() except +
+
+ @staticmethod
+ TBlob NoCopy(const void* data, size_t length) except +
+
+ @staticmethod
+ TBlob Copy(const void* data, size_t length) except +
+
+ @staticmethod
+ TBlob FromFile(const TString& path) except +
+
+ @staticmethod
+ TBlob PrechargedFromFile(const TString& path) except +
+
+ @staticmethod
+ TBlob FromString(const TString& s) except +
+
+ ui8& operator[](size_t) const
+ TBlob& operator=(TBlob&)
+
+
diff --git a/util/memory/blob_ut.pyx b/util/memory/blob_ut.pyx
index e72ec8f930..2332e6fa20 100644
--- a/util/memory/blob_ut.pyx
+++ b/util/memory/blob_ut.pyx
@@ -1,141 +1,141 @@
-# cython: c_string_type=str, c_string_encoding=utf8
-
-from libcpp.string cimport string as std_string
-from util.generic.string cimport TString
-from util.memory.blob cimport TBlob
-
-import pytest
-import unittest
-
-
-class TestBlob(unittest.TestCase):
- def test_ctor(self):
- cdef TBlob tmp = TBlob()
- cdef TBlob tmp2 = TBlob(tmp)
- self.assertEquals(tmp.Size(), 0)
- self.assertEquals(tmp2.Size(), 0)
-
- def test_empty_data(self):
- cdef TBlob tmp = TBlob()
- self.assertEquals(tmp.Data() == NULL, True)
- self.assertEquals(tmp.AsCharPtr() == NULL, True)
- self.assertEquals(tmp.AsUnsignedCharPtr() == NULL, True)
- self.assertEquals(tmp.Empty(), True)
- self.assertEquals(tmp.IsNull(), True)
-
- def test_empty_is_null(self):
- cdef TBlob tmp = TBlob.NoCopy("", 0)
- self.assertEquals(tmp.Empty(), True)
- self.assertEquals(tmp.IsNull(), False)
-
- def test_data_types(self):
- cdef const char* char_data = TBlob().AsCharPtr()
- cdef const unsigned char* uchar_data = TBlob().AsUnsignedCharPtr()
- cdef const void* void_data = TBlob().Data()
-
- def test_no_copy(self):
- cdef const char* txt = "hello world"
- cdef TBlob tmp = TBlob.NoCopy(txt, len(txt))
- self.assertEquals(tmp.AsCharPtr() - txt, 0)
- self.assertEquals(tmp.Size(), 11)
- self.assertEquals(tmp.AsCharPtr()[:tmp.Size()], "hello world")
- self.assertEquals(tmp.Empty(), False)
- self.assertEquals(tmp.IsNull(), False)
-
- def test_copy(self):
- cdef const char* txt = "hello world"
- cdef TBlob tmp = TBlob.Copy(txt, len(txt))
- self.assertNotEquals(tmp.AsCharPtr() - txt, 0)
- self.assertEquals(tmp.Size(), 11)
- self.assertEquals(tmp.AsCharPtr()[:tmp.Size()], "hello world")
- self.assertEquals(tmp.Empty(), False)
- self.assertEquals(tmp.IsNull(), False)
-
- def test_from_string(self):
- cdef TBlob tmp = TBlob.FromString(TString("hello world"))
- self.assertEquals(tmp.Size(), 11)
- self.assertEquals(tmp.AsCharPtr()[:tmp.Size()], "hello world")
- self.assertEquals(tmp.Empty(), False)
- self.assertEquals(tmp.IsNull(), False)
-
- def test_from_file(self):
- with open("file", "w") as f:
- f.write("hello world")
- cdef TBlob tmp = TBlob.FromFile("file")
- self.assertEquals(tmp.Size(), 11)
- self.assertEquals(tmp.AsCharPtr()[:tmp.Size()], "hello world")
- self.assertEquals(tmp.Empty(), False)
- self.assertEquals(tmp.IsNull(), False)
-
- def test_precharged_from_file(self):
- with open("precharged", "w") as f:
- f.write("hello world")
- cdef TBlob tmp = TBlob.PrechargedFromFile("precharged")
- self.assertEquals(tmp.Size(), 11)
- self.assertEquals(tmp.AsCharPtr()[:tmp.Size()], "hello world")
- self.assertEquals(tmp.Empty(), False)
- self.assertEquals(tmp.IsNull(), False)
-
- def test_swap_drop(self):
- cdef TBlob tmp = TBlob.NoCopy("hello world", 11)
- cdef TBlob tmp2
- tmp2.Swap(tmp)
- self.assertEquals(tmp2.Size(), 11)
- self.assertEquals(tmp.Size(), 0)
- self.assertEquals(tmp2.AsCharPtr()[:tmp2.Size()], "hello world")
- tmp2.Swap(tmp)
- self.assertEquals(tmp2.Size(), 0)
- self.assertEquals(tmp.Size(), 11)
- tmp.Drop()
- self.assertEquals(tmp.Size(), 0)
-
- def test_operator_brackets(self):
- cdef TBlob tmp = TBlob.NoCopy("hello world", 11)
- self.assertEquals(tmp[0], ord('h'))
- self.assertEquals(tmp[1], ord('e'))
- self.assertEquals(tmp[2], ord('l'))
- self.assertEquals(tmp[3], ord('l'))
- self.assertEquals(tmp[4], ord('o'))
- self.assertEquals(tmp[5], ord(' '))
- self.assertEquals(tmp[6], ord('w'))
- self.assertEquals(tmp[7], ord('o'))
- self.assertEquals(tmp[8], ord('r'))
- self.assertEquals(tmp[9], ord('l'))
- self.assertEquals(tmp[10], ord('d'))
-
- def test_operator_equal(self):
- cdef TBlob foo = TBlob.NoCopy("foo", 3)
- cdef TBlob bar = TBlob.NoCopy("bar", 3)
- self.assertEquals(foo.AsCharPtr(), "foo")
- self.assertEquals(bar.AsCharPtr(), "bar")
- bar = foo
- self.assertEquals(foo.AsCharPtr(), "foo")
- self.assertEquals(bar.AsCharPtr(), "foo")
-
- def test_sub_blob(self):
- cdef TBlob tmp = TBlob.NoCopy("hello world", 11)
- self.assertEquals(tmp.SubBlob(0).Size(), 0)
- self.assertEquals(tmp.SubBlob(1).Size(), 1)
- self.assertEquals(tmp.SubBlob(5).Size(), 5)
- self.assertEquals(tmp.AsCharPtr() - tmp.SubBlob(0).AsCharPtr(), 0)
-
- self.assertEquals(tmp.SubBlob(0, 0).Size(), 0)
- self.assertEquals(tmp.SubBlob(0, 1).Size(), 1)
- self.assertEquals(tmp.SubBlob(0, 5).Size(), 5)
- self.assertEquals(tmp.AsCharPtr() - tmp.SubBlob(0, 0).AsCharPtr(), 0)
-
- self.assertEquals(tmp.SubBlob(1, 1).Size(), 0)
- self.assertEquals(tmp.SubBlob(1, 2).Size(), 1)
- self.assertEquals(tmp.SubBlob(1, 6).Size(), 5)
- self.assertEquals(tmp.SubBlob(1, 1).AsCharPtr() - tmp.AsCharPtr(), 1)
-
- with self.assertRaises(Exception):
- tmp.SubBlob(2, 1)
-
- def test_deep_copy(self):
- cdef TBlob tmp = TBlob.NoCopy("hello world", 11)
- cdef TBlob tmp2 = tmp.DeepCopy()
- self.assertEquals(tmp.AsCharPtr()[:tmp.Size()], "hello world")
- self.assertEquals(tmp2.AsCharPtr()[:tmp2.Size()], "hello world")
- self.assertNotEquals(tmp2.AsCharPtr() - tmp.AsCharPtr(), 0)
-
+# cython: c_string_type=str, c_string_encoding=utf8
+
+from libcpp.string cimport string as std_string
+from util.generic.string cimport TString
+from util.memory.blob cimport TBlob
+
+import pytest
+import unittest
+
+
+class TestBlob(unittest.TestCase):
+ def test_ctor(self):
+ cdef TBlob tmp = TBlob()
+ cdef TBlob tmp2 = TBlob(tmp)
+ self.assertEquals(tmp.Size(), 0)
+ self.assertEquals(tmp2.Size(), 0)
+
+ def test_empty_data(self):
+ cdef TBlob tmp = TBlob()
+ self.assertEquals(tmp.Data() == NULL, True)
+ self.assertEquals(tmp.AsCharPtr() == NULL, True)
+ self.assertEquals(tmp.AsUnsignedCharPtr() == NULL, True)
+ self.assertEquals(tmp.Empty(), True)
+ self.assertEquals(tmp.IsNull(), True)
+
+ def test_empty_is_null(self):
+ cdef TBlob tmp = TBlob.NoCopy("", 0)
+ self.assertEquals(tmp.Empty(), True)
+ self.assertEquals(tmp.IsNull(), False)
+
+ def test_data_types(self):
+ cdef const char* char_data = TBlob().AsCharPtr()
+ cdef const unsigned char* uchar_data = TBlob().AsUnsignedCharPtr()
+ cdef const void* void_data = TBlob().Data()
+
+ def test_no_copy(self):
+ cdef const char* txt = "hello world"
+ cdef TBlob tmp = TBlob.NoCopy(txt, len(txt))
+ self.assertEquals(tmp.AsCharPtr() - txt, 0)
+ self.assertEquals(tmp.Size(), 11)
+ self.assertEquals(tmp.AsCharPtr()[:tmp.Size()], "hello world")
+ self.assertEquals(tmp.Empty(), False)
+ self.assertEquals(tmp.IsNull(), False)
+
+ def test_copy(self):
+ cdef const char* txt = "hello world"
+ cdef TBlob tmp = TBlob.Copy(txt, len(txt))
+ self.assertNotEquals(tmp.AsCharPtr() - txt, 0)
+ self.assertEquals(tmp.Size(), 11)
+ self.assertEquals(tmp.AsCharPtr()[:tmp.Size()], "hello world")
+ self.assertEquals(tmp.Empty(), False)
+ self.assertEquals(tmp.IsNull(), False)
+
+ def test_from_string(self):
+ cdef TBlob tmp = TBlob.FromString(TString("hello world"))
+ self.assertEquals(tmp.Size(), 11)
+ self.assertEquals(tmp.AsCharPtr()[:tmp.Size()], "hello world")
+ self.assertEquals(tmp.Empty(), False)
+ self.assertEquals(tmp.IsNull(), False)
+
+ def test_from_file(self):
+ with open("file", "w") as f:
+ f.write("hello world")
+ cdef TBlob tmp = TBlob.FromFile("file")
+ self.assertEquals(tmp.Size(), 11)
+ self.assertEquals(tmp.AsCharPtr()[:tmp.Size()], "hello world")
+ self.assertEquals(tmp.Empty(), False)
+ self.assertEquals(tmp.IsNull(), False)
+
+ def test_precharged_from_file(self):
+ with open("precharged", "w") as f:
+ f.write("hello world")
+ cdef TBlob tmp = TBlob.PrechargedFromFile("precharged")
+ self.assertEquals(tmp.Size(), 11)
+ self.assertEquals(tmp.AsCharPtr()[:tmp.Size()], "hello world")
+ self.assertEquals(tmp.Empty(), False)
+ self.assertEquals(tmp.IsNull(), False)
+
+ def test_swap_drop(self):
+ cdef TBlob tmp = TBlob.NoCopy("hello world", 11)
+ cdef TBlob tmp2
+ tmp2.Swap(tmp)
+ self.assertEquals(tmp2.Size(), 11)
+ self.assertEquals(tmp.Size(), 0)
+ self.assertEquals(tmp2.AsCharPtr()[:tmp2.Size()], "hello world")
+ tmp2.Swap(tmp)
+ self.assertEquals(tmp2.Size(), 0)
+ self.assertEquals(tmp.Size(), 11)
+ tmp.Drop()
+ self.assertEquals(tmp.Size(), 0)
+
+ def test_operator_brackets(self):
+ cdef TBlob tmp = TBlob.NoCopy("hello world", 11)
+ self.assertEquals(tmp[0], ord('h'))
+ self.assertEquals(tmp[1], ord('e'))
+ self.assertEquals(tmp[2], ord('l'))
+ self.assertEquals(tmp[3], ord('l'))
+ self.assertEquals(tmp[4], ord('o'))
+ self.assertEquals(tmp[5], ord(' '))
+ self.assertEquals(tmp[6], ord('w'))
+ self.assertEquals(tmp[7], ord('o'))
+ self.assertEquals(tmp[8], ord('r'))
+ self.assertEquals(tmp[9], ord('l'))
+ self.assertEquals(tmp[10], ord('d'))
+
+ def test_operator_equal(self):
+ cdef TBlob foo = TBlob.NoCopy("foo", 3)
+ cdef TBlob bar = TBlob.NoCopy("bar", 3)
+ self.assertEquals(foo.AsCharPtr(), "foo")
+ self.assertEquals(bar.AsCharPtr(), "bar")
+ bar = foo
+ self.assertEquals(foo.AsCharPtr(), "foo")
+ self.assertEquals(bar.AsCharPtr(), "foo")
+
+ def test_sub_blob(self):
+ cdef TBlob tmp = TBlob.NoCopy("hello world", 11)
+ self.assertEquals(tmp.SubBlob(0).Size(), 0)
+ self.assertEquals(tmp.SubBlob(1).Size(), 1)
+ self.assertEquals(tmp.SubBlob(5).Size(), 5)
+ self.assertEquals(tmp.AsCharPtr() - tmp.SubBlob(0).AsCharPtr(), 0)
+
+ self.assertEquals(tmp.SubBlob(0, 0).Size(), 0)
+ self.assertEquals(tmp.SubBlob(0, 1).Size(), 1)
+ self.assertEquals(tmp.SubBlob(0, 5).Size(), 5)
+ self.assertEquals(tmp.AsCharPtr() - tmp.SubBlob(0, 0).AsCharPtr(), 0)
+
+ self.assertEquals(tmp.SubBlob(1, 1).Size(), 0)
+ self.assertEquals(tmp.SubBlob(1, 2).Size(), 1)
+ self.assertEquals(tmp.SubBlob(1, 6).Size(), 5)
+ self.assertEquals(tmp.SubBlob(1, 1).AsCharPtr() - tmp.AsCharPtr(), 1)
+
+ with self.assertRaises(Exception):
+ tmp.SubBlob(2, 1)
+
+ def test_deep_copy(self):
+ cdef TBlob tmp = TBlob.NoCopy("hello world", 11)
+ cdef TBlob tmp2 = tmp.DeepCopy()
+ self.assertEquals(tmp.AsCharPtr()[:tmp.Size()], "hello world")
+ self.assertEquals(tmp2.AsCharPtr()[:tmp2.Size()], "hello world")
+ self.assertNotEquals(tmp2.AsCharPtr() - tmp.AsCharPtr(), 0)
+
diff --git a/util/stream/output.pxd b/util/stream/output.pxd
index 9e8198167b..2fccc26d9b 100644
--- a/util/stream/output.pxd
+++ b/util/stream/output.pxd
@@ -1,12 +1,12 @@
-from util.generic.string cimport TStringBuf
-
-
-cdef extern from "<util/stream/output.h>" nogil:
- cdef cppclass IOutputStream:
- IOutputStream()
- void Flush() except+
- void Finish() except+
-
- void WriteChar "Write"(char) except+
- void WriteBuf "Write"(const TStringBuf) except+
- void Write(const void*, size_t) except+
+from util.generic.string cimport TStringBuf
+
+
+cdef extern from "<util/stream/output.h>" nogil:
+ cdef cppclass IOutputStream:
+ IOutputStream()
+ void Flush() except+
+ void Finish() except+
+
+ void WriteChar "Write"(char) except+
+ void WriteBuf "Write"(const TStringBuf) except+
+ void Write(const void*, size_t) except+
diff --git a/util/stream/str.pxd b/util/stream/str.pxd
index bfdb071559..76dc16a822 100644
--- a/util/stream/str.pxd
+++ b/util/stream/str.pxd
@@ -1,12 +1,12 @@
-from util.generic.ptr cimport THolder
-from util.generic.string cimport TString, TStringBuf
-from util.stream.output cimport IOutputStream
-
-
-cdef extern from "<util/stream/str.h>" nogil:
- cdef cppclass TStringOutput(IOutputStream):
- TStringOutput() except+
- TStringOutput(TString&) except+
- void Reserve(size_t) except+
-
-ctypedef THolder[TStringOutput] TStringOutputPtr
+from util.generic.ptr cimport THolder
+from util.generic.string cimport TString, TStringBuf
+from util.stream.output cimport IOutputStream
+
+
+cdef extern from "<util/stream/str.h>" nogil:
+ cdef cppclass TStringOutput(IOutputStream):
+ TStringOutput() except+
+ TStringOutput(TString&) except+
+ void Reserve(size_t) except+
+
+ctypedef THolder[TStringOutput] TStringOutputPtr
diff --git a/util/stream/str_ut.pyx b/util/stream/str_ut.pyx
index 17bf222250..2ae617303f 100644
--- a/util/stream/str_ut.pyx
+++ b/util/stream/str_ut.pyx
@@ -1,62 +1,62 @@
-# cython: c_string_type=str, c_string_encoding=utf8
-
-from cython.operator cimport dereference
-
-from util.generic.ptr cimport THolder
-from util.generic.string cimport TString, TStringBuf
-from util.stream.str cimport TStringOutput, TStringOutputPtr
-
-import unittest
-
-
-class TestStringOutput(unittest.TestCase):
- def test_ctor1(self):
- cdef TStringOutput output
-
- def test_ctor2(self):
- cdef TString string
- cdef THolder[TStringOutput] string_output = THolder[TStringOutput](new TStringOutput(string))
-
- def test_write_char(self):
- cdef TString string
- cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string))
-
- self.assertEqual(string, "")
- dereference(string_output.Get()).WriteChar('1')
- self.assertEqual(string, "1")
- dereference(string_output.Get()).WriteChar('2')
- self.assertEqual(string, "12")
- dereference(string_output.Get()).WriteChar('3')
- self.assertEqual(string, "123")
-
- def test_write_void(self):
- cdef TString string
- cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string))
-
- self.assertEqual(string, "")
- dereference(string_output.Get()).Write("1", 1)
- self.assertEqual(string, "1")
- dereference(string_output.Get()).Write("2", 1)
- self.assertEqual(string, "12")
- dereference(string_output.Get()).Write("34", 2)
- self.assertEqual(string, "1234")
-
- def test_write_buf(self):
- cdef TString string
- cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string))
-
- self.assertEqual(string, "")
- dereference(string_output.Get()).WriteBuf(TStringBuf("1"))
- self.assertEqual(string, "1")
- dereference(string_output.Get()).WriteBuf(TStringBuf("2"))
- self.assertEqual(string, "12")
- dereference(string_output.Get()).WriteBuf(TStringBuf("34"))
- self.assertEqual(string, "1234")
-
- def test_reserve(self):
- cdef TString string
- cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string))
- self.assertEqual(string, "")
- dereference(string_output.Get()).Reserve(50)
- self.assertEqual(string, "")
- self.assertLessEqual(50, string.capacity())
+# cython: c_string_type=str, c_string_encoding=utf8
+
+from cython.operator cimport dereference
+
+from util.generic.ptr cimport THolder
+from util.generic.string cimport TString, TStringBuf
+from util.stream.str cimport TStringOutput, TStringOutputPtr
+
+import unittest
+
+
+class TestStringOutput(unittest.TestCase):
+ def test_ctor1(self):
+ cdef TStringOutput output
+
+ def test_ctor2(self):
+ cdef TString string
+ cdef THolder[TStringOutput] string_output = THolder[TStringOutput](new TStringOutput(string))
+
+ def test_write_char(self):
+ cdef TString string
+ cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string))
+
+ self.assertEqual(string, "")
+ dereference(string_output.Get()).WriteChar('1')
+ self.assertEqual(string, "1")
+ dereference(string_output.Get()).WriteChar('2')
+ self.assertEqual(string, "12")
+ dereference(string_output.Get()).WriteChar('3')
+ self.assertEqual(string, "123")
+
+ def test_write_void(self):
+ cdef TString string
+ cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string))
+
+ self.assertEqual(string, "")
+ dereference(string_output.Get()).Write("1", 1)
+ self.assertEqual(string, "1")
+ dereference(string_output.Get()).Write("2", 1)
+ self.assertEqual(string, "12")
+ dereference(string_output.Get()).Write("34", 2)
+ self.assertEqual(string, "1234")
+
+ def test_write_buf(self):
+ cdef TString string
+ cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string))
+
+ self.assertEqual(string, "")
+ dereference(string_output.Get()).WriteBuf(TStringBuf("1"))
+ self.assertEqual(string, "1")
+ dereference(string_output.Get()).WriteBuf(TStringBuf("2"))
+ self.assertEqual(string, "12")
+ dereference(string_output.Get()).WriteBuf(TStringBuf("34"))
+ self.assertEqual(string, "1234")
+
+ def test_reserve(self):
+ cdef TString string
+ cdef TStringOutputPtr string_output = TStringOutputPtr(new TStringOutput(string))
+ self.assertEqual(string, "")
+ dereference(string_output.Get()).Reserve(50)
+ self.assertEqual(string, "")
+ self.assertLessEqual(50, string.capacity())
diff --git a/util/string/cast_ut.pyx b/util/string/cast_ut.pyx
index c925000f90..88e86ef961 100644
--- a/util/string/cast_ut.pyx
+++ b/util/string/cast_ut.pyx
@@ -1,5 +1,5 @@
-# cython: c_string_type=str, c_string_encoding=utf8
-
+# cython: c_string_type=str, c_string_encoding=utf8
+
from util.string.cast cimport FromString, ToString
import unittest
diff --git a/util/tests/cython/test_folder.py b/util/tests/cython/test_folder.py
index 25c94e6311..ca176ab2a5 100644
--- a/util/tests/cython/test_folder.py
+++ b/util/tests/cython/test_folder.py
@@ -1,12 +1,12 @@
-# -*- coding: utf-8 -*-
-
-from __future__ import print_function, absolute_import, division
-
-from util.folder.path_ut import TestPath
-
-# Test discovery does not work in cython modules.
-# Reexporting test classes here to satisfy pylint and pytest.
-
-__all__ = [
- 'TestPath',
-]
+# -*- coding: utf-8 -*-
+
+from __future__ import print_function, absolute_import, division
+
+from util.folder.path_ut import TestPath
+
+# Test discovery does not work in cython modules.
+# Reexporting test classes here to satisfy pylint and pytest.
+
+__all__ = [
+ 'TestPath',
+]
diff --git a/util/tests/cython/test_generic.py b/util/tests/cython/test_generic.py
index d1f48c17bf..a0d61339cc 100644
--- a/util/tests/cython/test_generic.py
+++ b/util/tests/cython/test_generic.py
@@ -2,10 +2,10 @@
from __future__ import print_function, absolute_import, division
-from util.generic.deque_ut import TestDeque
+from util.generic.deque_ut import TestDeque
from util.generic.hash_ut import TestHash
-from util.generic.hash_set_ut import TestHashSet
-from util.generic.list_ut import TestList
+from util.generic.hash_set_ut import TestHashSet
+from util.generic.list_ut import TestList
from util.generic.maybe_ut import TestMaybe
from util.generic.ptr_ut import TestHolder
from util.generic.string_ut import TestStroka
@@ -16,11 +16,11 @@ from util.string.cast_ut import TestFromString, TestToString
# Reexporting test classes here to satisfy pylint and pytest.
__all__ = [
- 'TestDeque',
+ 'TestDeque',
'TestHash',
- 'TestHashSet',
- 'TestHolder',
- 'TestList',
+ 'TestHashSet',
+ 'TestHolder',
+ 'TestList',
'TestMaybe',
'TestStroka',
'TestVector',
diff --git a/util/tests/cython/test_memory.py b/util/tests/cython/test_memory.py
index 02d00dc422..705f384726 100644
--- a/util/tests/cython/test_memory.py
+++ b/util/tests/cython/test_memory.py
@@ -1,12 +1,12 @@
-# -*- coding: utf-8 -*-
-
-from __future__ import print_function, absolute_import, division
-
-from util.memory.blob_ut import TestBlob
-
-# Test discovery does not work in cython modules.
-# Reexporting test classes here to satisfy pylint and pytest.
-
-__all__ = [
- 'TestBlob',
-]
+# -*- coding: utf-8 -*-
+
+from __future__ import print_function, absolute_import, division
+
+from util.memory.blob_ut import TestBlob
+
+# Test discovery does not work in cython modules.
+# Reexporting test classes here to satisfy pylint and pytest.
+
+__all__ = [
+ 'TestBlob',
+]
diff --git a/util/tests/cython/test_stream.py b/util/tests/cython/test_stream.py
index ff0a052b4c..6abfe1de0d 100644
--- a/util/tests/cython/test_stream.py
+++ b/util/tests/cython/test_stream.py
@@ -1,12 +1,12 @@
-# -*- coding: utf-8 -*-
-
-from __future__ import print_function, absolute_import, division
-
-from util.stream.str_ut import TestStringOutput
-
-# Test discovery does not work in cython modules.
-# Reexporting test classes here to satisfy pylint and pytest.
-
-__all__ = [
- 'TestStringOutput',
-]
+# -*- coding: utf-8 -*-
+
+from __future__ import print_function, absolute_import, division
+
+from util.stream.str_ut import TestStringOutput
+
+# Test discovery does not work in cython modules.
+# Reexporting test classes here to satisfy pylint and pytest.
+
+__all__ = [
+ 'TestStringOutput',
+]
diff --git a/util/tests/cython/ya.make b/util/tests/cython/ya.make
index 231338b6a4..b928c19026 100644
--- a/util/tests/cython/ya.make
+++ b/util/tests/cython/ya.make
@@ -1,4 +1,4 @@
-PY23_TEST()
+PY23_TEST()
OWNER(g:util)
SUBSCRIBER(g:util-subscribers)
@@ -10,9 +10,9 @@ NO_WSHADOW()
PY_SRCS(
NAMESPACE
util
- folder/path_ut.pyx
+ folder/path_ut.pyx
generic/array_ref_ut.pyx
- generic/deque_ut.pyx
+ generic/deque_ut.pyx
generic/maybe_ut.pyx
generic/ptr_ut.pyx
generic/string_ut.pyx
@@ -20,19 +20,19 @@ PY_SRCS(
generic/list_ut.pyx
generic/hash_set_ut.pyx
generic/hash_ut.pyx
- memory/blob_ut.pyx
- stream/str_ut.pyx
+ memory/blob_ut.pyx
+ stream/str_ut.pyx
string/cast_ut.pyx
system/types_ut.pyx
digest/multi_ut.pyx
)
TEST_SRCS(
- test_digest.py
- test_folder.py
+ test_digest.py
+ test_folder.py
test_generic.py
- test_memory.py
- test_stream.py
+ test_memory.py
+ test_stream.py
test_system.py
)
diff --git a/ydb/core/blobstorage/ut_blobstorage/lib/env.h b/ydb/core/blobstorage/ut_blobstorage/lib/env.h
index 4931b0209b..1cc05f00bf 100644
--- a/ydb/core/blobstorage/ut_blobstorage/lib/env.h
+++ b/ydb/core/blobstorage/ut_blobstorage/lib/env.h
@@ -65,7 +65,7 @@ struct TEnvironmentSetup {
TBlobStorageGroupType erasure = TBlobStorageGroupType::ErasureNone)
: TEnvironmentSetup(TSettings{
.NodeCount = nodeCount,
- .Erasure = erasure,
+ .Erasure = erasure,
.NodeWardenMockSetup = std::move(nodeWardenMockSetup),
})
{}
diff --git a/ydb/core/blobstorage/vdisk/skeleton/skeleton_capturevdisklayout.h b/ydb/core/blobstorage/vdisk/skeleton/skeleton_capturevdisklayout.h
index b69de3520e..aca411bafc 100644
--- a/ydb/core/blobstorage/vdisk/skeleton/skeleton_capturevdisklayout.h
+++ b/ydb/core/blobstorage/vdisk/skeleton/skeleton_capturevdisklayout.h
@@ -3,8 +3,8 @@
namespace NKikimr {
class TCaptureVDiskLayoutActor : public TActorBootstrapped<TCaptureVDiskLayoutActor> {
- using TRes = TEvBlobStorage::TEvCaptureVDiskLayoutResult;
-
+ using TRes = TEvBlobStorage::TEvCaptureVDiskLayoutResult;
+
TEvBlobStorage::TEvCaptureVDiskLayout::TPtr Ev;
THullDsSnap Snap;
diff --git a/ydb/core/util/stlog.h b/ydb/core/util/stlog.h
index 17fe77160d..de6cea2131 100644
--- a/ydb/core/util/stlog.h
+++ b/ydb/core/util/stlog.h
@@ -64,8 +64,8 @@ namespace NKikimr::NStLog {
auto getPrio = [&] { using namespace NActors::NLog; return (PRIO); }; \
auto getComp = [&] { using namespace NKikimrServices; using namespace NActorsServices; return (COMP); }; \
auto makeMessage = [&] { \
- struct MARKER {}; \
- using Tag = MARKER; \
+ struct MARKER {}; \
+ using Tag = MARKER; \
return ::NKikimr::NStLog::TMessage<Tag>(__FILE__, __LINE__, #MARKER, TStringBuilder() << TEXT) \
STLOG_PARAMS(__VA_ARGS__); \
}; \