1
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2026-03-10 02:37:59 +01:00

refactor(black): black 26 applied

This commit is contained in:
2026-03-06 10:25:45 +01:00
committed by Jan Wyzula
parent e157f0d7c9
commit d4e037f338
24 changed files with 88 additions and 166 deletions

View File

@@ -38,8 +38,7 @@ def developer_view(qtbot, mocked_client):
def temp_python_file():
"""Create a temporary Python file for testing."""
with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f:
f.write(
"""# Test Python file
f.write("""# Test Python file
import os
import sys
@@ -48,8 +47,7 @@ def test_function():
if __name__ == "__main__":
print(test_function())
"""
)
""")
temp_file_path = f.name
yield temp_file_path

View File

@@ -88,8 +88,7 @@ def test_client_generator_with_black_formatting():
generator.generate_client(container)
# Format the expected output with black to ensure it matches the generator output
expected_output = dedent(
'''\
expected_output = dedent('''\
# This file was automatically generated by generate_cli.py
# type: ignore
@@ -174,8 +173,7 @@ def test_client_generator_with_black_formatting():
"""
Set the amplitude of the waveform.
"""
'''
)
''')
expected_output_formatted = black.format_str(
expected_output, mode=black.FileMode(line_length=100)

View File

@@ -68,21 +68,17 @@ def test_shared_macros_section_with_files(ide_explorer, tmpdir):
"""Test that shared macros section is created when plugin directory has files"""
# Create dummy shared macro files
shared_macros_dir = tmpdir.mkdir("shared_macros")
shared_macros_dir.join("shared_macro1.py").write(
"""
shared_macros_dir.join("shared_macro1.py").write("""
def shared_function1():
return "shared1"
def shared_function2():
return "shared2"
"""
)
shared_macros_dir.join("utilities.py").write(
"""
""")
shared_macros_dir.join("utilities.py").write("""
def utility_function():
return "utility"
"""
)
""")
with mock.patch.object(ide_explorer, "_get_plugin_dir") as mock_get_plugin_dir:
mock_get_plugin_dir.return_value = str(shared_macros_dir)

View File

@@ -20,8 +20,7 @@ def temp_macro_files(tmpdir):
# Create a simple macro file with functions
macro_file1 = macro_dir / "test_macros.py"
macro_file1.write_text(
'''
macro_file1.write_text('''
def test_macro_function():
"""A test macro function."""
return "test"
@@ -34,13 +33,11 @@ class TestClass:
"""This class should be ignored."""
def method(self):
pass
'''
)
''')
# Create another macro file
macro_file2 = macro_dir / "utils_macros.py"
macro_file2.write_text(
'''
macro_file2.write_text('''
def utility_function():
"""A utility function."""
pass
@@ -48,37 +45,30 @@ def utility_function():
def deprecated_function():
"""Old function."""
return None
'''
)
''')
# Create a file with no functions (should be ignored)
empty_file = macro_dir / "empty.py"
empty_file.write_text(
"""
empty_file.write_text("""
# Just a comment
x = 1
y = 2
"""
)
""")
# Create a file starting with underscore (should be ignored)
private_file = macro_dir / "_private.py"
private_file.write_text(
"""
private_file.write_text("""
def private_function():
return "private"
"""
)
""")
# Create a file with syntax errors
error_file = macro_dir / "error_file.py"
error_file.write_text(
"""
error_file.write_text("""
def broken_function(
# Missing closing parenthesis and colon
pass
"""
)
""")
return macro_dir
@@ -406,13 +396,11 @@ class TestMacroTreeRefresh:
# Add a new macro file
new_file = temp_macro_files / "new_macros.py"
new_file.write_text(
'''
new_file.write_text('''
def new_function():
"""A new function."""
return "new"
'''
)
''')
# Refresh the tree
macro_tree.refresh()
@@ -439,14 +427,12 @@ def new_function():
# Modify the file to add a new function
with open(test_file_path, "a") as f:
f.write(
'''
f.write('''
def newly_added_function():
"""A newly added function."""
return "added"
'''
)
''')
# Refresh just this file
macro_tree.refresh_file_item(test_file_path)