Skip to content

Commit d7e894b

Browse files
committed
linting fix
1 parent 12ad019 commit d7e894b

1 file changed

Lines changed: 36 additions & 72 deletions

File tree

tests/test_013_encoding_decoding.py

Lines changed: 36 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,15 +1078,13 @@ def test_setdecoding_with_unicode_data(db_connection):
10781078

10791079
try:
10801080
# Create test table with NVARCHAR columns for Unicode support
1081-
cursor.execute(
1082-
"""
1081+
cursor.execute("""
10831082
CREATE TABLE #test_decoding_unicode (
10841083
id INT IDENTITY(1,1),
10851084
ascii_col VARCHAR(100),
10861085
unicode_col NVARCHAR(100)
10871086
)
1088-
"""
1089-
)
1087+
""")
10901088

10911089
# Test ASCII strings in VARCHAR (safe)
10921090
ascii_strings = [
@@ -1161,17 +1159,15 @@ def test_encoding_decoding_comprehensive_unicode_characters(db_connection):
11611159

11621160
try:
11631161
# Create test table with different column types - use NVARCHAR for better Unicode support
1164-
cursor.execute(
1165-
"""
1162+
cursor.execute("""
11661163
CREATE TABLE #test_encoding_comprehensive (
11671164
id INT PRIMARY KEY,
11681165
varchar_col VARCHAR(1000),
11691166
nvarchar_col NVARCHAR(1000),
11701167
text_col TEXT,
11711168
ntext_col NTEXT
11721169
)
1173-
"""
1174-
)
1170+
""")
11751171

11761172
# Test cases with different Unicode character categories
11771173
test_cases = [
@@ -1333,8 +1329,7 @@ def test_encoding_decoding_edge_case_data_types(db_connection):
13331329

13341330
try:
13351331
# Create table with various data types
1336-
cursor.execute(
1337-
"""
1332+
cursor.execute("""
13381333
CREATE TABLE #test_encoding_datatypes (
13391334
id INT PRIMARY KEY,
13401335
varchar_small VARCHAR(50),
@@ -1346,8 +1341,7 @@ def test_encoding_decoding_edge_case_data_types(db_connection):
13461341
text_type TEXT,
13471342
ntext_type NTEXT
13481343
)
1349-
"""
1350-
)
1344+
""")
13511345

13521346
# Test different encoding configurations
13531347
test_configs = [
@@ -1639,16 +1633,14 @@ def test_encoding_decoding_large_dataset_performance(db_connection):
16391633
cursor = db_connection.cursor()
16401634

16411635
try:
1642-
cursor.execute(
1643-
"""
1636+
cursor.execute("""
16441637
CREATE TABLE #test_large_encoding (
16451638
id INT PRIMARY KEY,
16461639
ascii_data VARCHAR(1000),
16471640
unicode_data NVARCHAR(1000),
16481641
mixed_data NVARCHAR(MAX)
16491642
)
1650-
"""
1651-
)
1643+
""")
16521644

16531645
# Generate test data - ensure it fits in column sizes
16541646
ascii_text = "This is ASCII text with numbers 12345." * 10 # ~400 chars
@@ -1817,15 +1809,13 @@ def test_encoding_decoding_metadata_columns(db_connection):
18171809

18181810
try:
18191811
# Create table with Unicode column names if supported
1820-
cursor.execute(
1821-
"""
1812+
cursor.execute("""
18221813
CREATE TABLE #test_metadata (
18231814
[normal_col] NVARCHAR(100),
18241815
[column_with_unicode_测试] NVARCHAR(100),
18251816
[special_chars_ñáéíóú] INT
18261817
)
1827-
"""
1828-
)
1818+
""")
18291819

18301820
# Test metadata decoding configuration
18311821
db_connection.setdecoding(mssql_python.SQL_WMETADATA, encoding="utf-16le", ctype=SQL_WCHAR)
@@ -1899,17 +1889,15 @@ def test_encoding_decoding_stress_test_comprehensive(db_connection):
18991889
cursor = db_connection.cursor()
19001890

19011891
try:
1902-
cursor.execute(
1903-
"""
1892+
cursor.execute("""
19041893
CREATE TABLE #stress_test_encoding (
19051894
id INT IDENTITY(1,1) PRIMARY KEY,
19061895
ascii_text VARCHAR(500),
19071896
unicode_text NVARCHAR(500),
19081897
binary_data VARBINARY(500),
19091898
mixed_content NVARCHAR(MAX)
19101899
)
1911-
"""
1912-
)
1900+
""")
19131901

19141902
# Generate diverse test data
19151903
test_datasets = []
@@ -2030,15 +2018,13 @@ def test_encoding_decoding_sql_char_various_encodings(db_connection):
20302018

20312019
try:
20322020
# Create test table with VARCHAR columns (SQL_CHAR type)
2033-
cursor.execute(
2034-
"""
2021+
cursor.execute("""
20352022
CREATE TABLE #test_sql_char_encodings (
20362023
id INT PRIMARY KEY,
20372024
data_col VARCHAR(100),
20382025
description VARCHAR(200)
20392026
)
2040-
"""
2041-
)
2027+
""")
20422028

20432029
# Define various encoding types to test with SQL_CHAR
20442030
encoding_tests = [
@@ -2315,15 +2301,13 @@ def test_encoding_decoding_sql_char_with_unicode_fallback(db_connection):
23152301

23162302
try:
23172303
# Create test table with both VARCHAR and NVARCHAR
2318-
cursor.execute(
2319-
"""
2304+
cursor.execute("""
23202305
CREATE TABLE #test_unicode_fallback (
23212306
id INT PRIMARY KEY,
23222307
varchar_data VARCHAR(100),
23232308
nvarchar_data NVARCHAR(100)
23242309
)
2325-
"""
2326-
)
2310+
""")
23272311

23282312
# Test Unicode data
23292313
unicode_test_cases = [
@@ -2394,15 +2378,13 @@ def test_encoding_decoding_sql_char_native_character_sets(db_connection):
23942378

23952379
try:
23962380
# Create test table
2397-
cursor.execute(
2398-
"""
2381+
cursor.execute("""
23992382
CREATE TABLE #test_native_chars (
24002383
id INT PRIMARY KEY,
24012384
data VARCHAR(200),
24022385
encoding_used VARCHAR(50)
24032386
)
2404-
"""
2405-
)
2387+
""")
24062388

24072389
# Test encoding-specific character sets that should work
24082390
encoding_native_tests = [
@@ -2537,15 +2519,13 @@ def test_encoding_decoding_sql_char_boundary_encoding_cases(db_connection):
25372519

25382520
try:
25392521
# Create test table
2540-
cursor.execute(
2541-
"""
2522+
cursor.execute("""
25422523
CREATE TABLE #test_encoding_boundaries (
25432524
id INT PRIMARY KEY,
25442525
test_data VARCHAR(500),
25452526
test_type VARCHAR(100)
25462527
)
2547-
"""
2548-
)
2528+
""")
25492529

25502530
# Test boundary cases for different encodings
25512531
boundary_tests = [
@@ -2646,16 +2626,14 @@ def test_encoding_decoding_sql_char_unicode_issue_diagnosis(db_connection):
26462626

26472627
try:
26482628
# Create test table with both VARCHAR and NVARCHAR for comparison
2649-
cursor.execute(
2650-
"""
2629+
cursor.execute("""
26512630
CREATE TABLE #test_unicode_issue (
26522631
id INT PRIMARY KEY,
26532632
varchar_col VARCHAR(100),
26542633
nvarchar_col NVARCHAR(100),
26552634
encoding_used VARCHAR(50)
26562635
)
2657-
"""
2658-
)
2636+
""")
26592637

26602638
# Test Unicode strings that commonly cause issues
26612639
test_strings = [
@@ -2701,11 +2679,9 @@ def test_encoding_decoding_sql_char_unicode_issue_diagnosis(db_connection):
27012679
)
27022680

27032681
# Retrieve results
2704-
cursor.execute(
2705-
"""
2682+
cursor.execute("""
27062683
SELECT varchar_col, nvarchar_col FROM #test_unicode_issue WHERE id = 1
2707-
"""
2708-
)
2684+
""")
27092685
result = cursor.fetchone()
27102686

27112687
if result:
@@ -2760,8 +2736,7 @@ def test_encoding_decoding_sql_char_best_practices_guide(db_connection):
27602736

27612737
try:
27622738
# Create test table demonstrating different column types
2763-
cursor.execute(
2764-
"""
2739+
cursor.execute("""
27652740
CREATE TABLE #test_best_practices (
27662741
id INT PRIMARY KEY,
27672742
-- ASCII-safe columns (VARCHAR with SQL_CHAR)
@@ -2775,8 +2750,7 @@ def test_encoding_decoding_sql_char_best_practices_guide(db_connection):
27752750
-- Mixed approach column
27762751
safe_text VARCHAR(200)
27772752
)
2778-
"""
2779-
)
2753+
""")
27802754

27812755
# Configure optimal settings
27822756
db_connection.setencoding(encoding="utf-8", ctype=SQL_CHAR) # For ASCII data
@@ -4992,15 +4966,13 @@ def test_execute_executemany_encoding_consistency(db_connection):
49924966

49934967
try:
49944968
# Create test table that can handle both VARCHAR and NVARCHAR data
4995-
cursor.execute(
4996-
"""
4969+
cursor.execute("""
49974970
CREATE TABLE #test_encoding_consistency (
49984971
id INT IDENTITY(1,1) PRIMARY KEY,
49994972
varchar_col VARCHAR(1000) COLLATE SQL_Latin1_General_CP1_CI_AS,
50004973
nvarchar_col NVARCHAR(1000)
50014974
)
5002-
"""
5003-
)
4975+
""")
50044976

50054977
# Test data with various encoding challenges
50064978
# Using ASCII-safe characters that work across different encodings
@@ -5053,13 +5025,11 @@ def test_execute_executemany_encoding_consistency(db_connection):
50535025
)
50545026

50555027
# Retrieve immediately to verify encoding worked
5056-
cursor.execute(
5057-
"""
5028+
cursor.execute("""
50585029
SELECT varchar_col, nvarchar_col
50595030
FROM #test_encoding_consistency
50605031
WHERE id = (SELECT MAX(id) FROM #test_encoding_consistency)
5061-
"""
5062-
)
5032+
""")
50635033
result = cursor.fetchone()
50645034
execute_results.append((result[0], result[1]))
50655035

@@ -5084,13 +5054,11 @@ def test_execute_executemany_encoding_consistency(db_connection):
50845054
)
50855055

50865056
# Retrieve all results from executemany
5087-
cursor.execute(
5088-
"""
5057+
cursor.execute("""
50895058
SELECT varchar_col, nvarchar_col
50905059
FROM #test_encoding_consistency
50915060
ORDER BY id
5092-
"""
5093-
)
5061+
""")
50945062
executemany_results = cursor.fetchall()
50955063

50965064
# Verify executemany results match execute results
@@ -5127,13 +5095,11 @@ def test_execute_executemany_encoding_consistency(db_connection):
51275095
test_string,
51285096
)
51295097

5130-
cursor.execute(
5131-
"""
5098+
cursor.execute("""
51325099
SELECT nvarchar_col
51335100
FROM #test_encoding_consistency
51345101
WHERE id = (SELECT MAX(id) FROM #test_encoding_consistency)
5135-
"""
5136-
)
5102+
""")
51375103
result = cursor.fetchone()
51385104
unicode_execute_results.append(result[0])
51395105

@@ -5160,13 +5126,11 @@ def test_execute_executemany_encoding_consistency(db_connection):
51605126
unicode_params,
51615127
)
51625128

5163-
cursor.execute(
5164-
"""
5129+
cursor.execute("""
51655130
SELECT nvarchar_col
51665131
FROM #test_encoding_consistency
51675132
ORDER BY id
5168-
"""
5169-
)
5133+
""")
51705134
unicode_executemany_results = cursor.fetchall()
51715135

51725136
# Compare Unicode results

0 commit comments

Comments
 (0)