Skip to content

Commit

Permalink
Remove rogue prints from tests, please use str() instead to test strings
Browse files Browse the repository at this point in the history
  • Loading branch information
PProfizi committed Jul 13, 2023
1 parent 026ef8b commit 47bf517
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions tests/test_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_cff_model(server_type, fluent_multi_species):
)
def test_results_cfx(cfx_heating_coil, server_type):
model = dpf.Model(cfx_heating_coil(server=server_type), server=server_type)
print(model)
# print(model)
result_names = [
"specific_heat",
"epsilon",
Expand Down Expand Up @@ -55,7 +55,7 @@ def test_results_cfx(cfx_heating_coil, server_type):
)
def test_results_fluent(fluent_mixing_elbow_steady_state, server_type):
model = dpf.Model(fluent_mixing_elbow_steady_state(server=server_type), server=server_type)
print(model)
# print(model)
result_names = [
"epsilon",
"enthalpy",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_codegeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def test_generated_operator_set_config():
inpt2.unit = "m"

conf = op.math.add.default_config()
print(conf)
# print(conf)
conf.set_work_by_index_option(True)
op1 = op.math.add(config=conf)
op1.inputs.fieldA.connect(inpt)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_custom_type_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_set_get_data_custom_type_field(server_type):
data[i] = np.byte(b"2")
field.data = data
assert np.allclose(field.data, data)
print(field.data)
# print(field.data)


@conftest.raises_for_servers_version_under("5.0")
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_set_get_field_def_custom_type_field(server_type):

copy = field.field_definition

print(copy.dimensionality)
# print(copy.dimensionality)
assert copy.dimensionality == dpf.core.Dimensionality([3], dpf.core.natures.vector)
assert copy.location == core.locations.elemental
assert copy.name == "thing"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_no_element_descriptor():
# descriptor = dpf.element_types.descriptor(89)
# assert not descriptor
descriptor = dpf.element_types.descriptor(dpf.element_types.General)
print(descriptor)
# print(descriptor)
unknown_shape = "unknown_shape"
assert descriptor.shape == unknown_shape
assert dpf.element_types.descriptor(dpf.element_types.General).shape == unknown_shape
Expand Down
2 changes: 1 addition & 1 deletion tests/test_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def test_elemental_scoping():

def test_named_selection_scoping(model_with_ns):
model = Model(model_with_ns)
print(model.metadata.available_named_selections)
# print(model.metadata.available_named_selections)
scop = mesh_scoping_factory.named_selection_scoping("SELECTION", model)
assert scop is not None
assert len(scop.ids) != 0
6 changes: 3 additions & 3 deletions tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_create_points():
points = rng.random((n_points, 3))
points = create_points(points)
points.plot()
print(points)
# print(points)
assert points.dimension == 3
assert len(points) == points.n_points == n_points

Expand Down Expand Up @@ -57,7 +57,7 @@ def test_create_line_from_points(points_param):
info += f"Starting point: {np.array(points[0])}\n"
info += f"Ending point: {np.array(points[1])}\n"
info += f"Line discretized with {line.n_points} points\n"
assert print(line) == print(info)
assert str(line) == str(info)
assert line.length == np.linalg.norm(points)
diff = np.array(points[1]) - np.array(points[0])
assert all(line.direction) == all(diff / np.linalg.norm(diff))
Expand Down Expand Up @@ -297,7 +297,7 @@ def test_plane_discretization(component):
info_discretization += f" Height (y-dir): {height}\n"
info_discretization += f" Num cells x-dir: {n_cells_x}\n"
info_discretization += f" Num cells y-dir: {n_cells_y}\n"
assert print(plane) == print(info_discretization)
assert str(plane) == str(info_discretization)


plane_mapping_data = [
Expand Down
4 changes: 2 additions & 2 deletions tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def test_launch_server_full_path(self, server_config):
else:
path = os.path.join(ansys_path, "aisol", "bin", "linx64")

print("trying to launch on ", path)
print(os.listdir(path))
# print("trying to launch on ", path)
# print(os.listdir(path))
server = core.start_local_server(as_global=False, ansys_path=path, config=server_config)
assert "server_port" in server.info

Expand Down
2 changes: 1 addition & 1 deletion tests/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_connect_bool_operator(server_type):

def test_print_operator():
op = dpf.core.Operator("S")
print(op)
assert str(op)


def test_connect_get_out_all_types_operator(server_type):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pathsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_print_data_sources_path(allkindofcomplexity):
path = Path(allkindofcomplexity)
data_sources = dpf.core.DataSources()
data_sources.set_result_file_path(path)
print(data_sources)
assert str(data_sources)
assert data_sources.result_key == "rst"
assert len(data_sources.result_files) == 1
assert os.path.normpath(data_sources.result_files[0]) == os.path.normpath(allkindofcomplexity)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_propertyfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def test_print_property_field(server_type):
scop = core.Scoping(ids=list_ids, location=locations.nodal, server=server_type)
pfield.scoping = scop
pfield.data = [1, 2, 4, 6, 7]
print(pfield)
# print(pfield)
assert "Property Field" in str(pfield)
assert "5" in str(pfield)
assert "Nodal" in str(pfield)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_scoping.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_print_scoping():
scop = Scoping()
ids = [1, 2, 3, 5, 8, 9, 10]
scop.ids = ids
print(scop)
assert str(scop)


def test_documentation_string_on_scoping(server_type):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def reset_server_config():

def test__global_server(self, server_config):
set_server_configuration(server_config)
print(dpf.core.SERVER_CONFIGURATION)
# print(dpf.core.SERVER_CONFIGURATION)
shutdown_all_session_servers()
_global_server()
assert has_local_server()
Expand All @@ -84,7 +84,7 @@ def test_set_server_configuration(self, server_config):

def test_start_local_server(self, server_config):
set_server_configuration(server_config)
print(dpf.core.SERVER_CONFIGURATION)
# print(dpf.core.SERVER_CONFIGURATION)
start_local_server(timeout=20)
assert has_local_server()
shutdown_all_session_servers()
Expand All @@ -98,7 +98,7 @@ def test_start_local_server_with_config(self, server_config):

def test_shutdown_all_session_servers(self, server_config):
set_server_configuration(server_config)
print(dpf.core.SERVER_CONFIGURATION)
# print(dpf.core.SERVER_CONFIGURATION)
start_local_server(timeout=10.0)
shutdown_all_session_servers()
assert not has_local_server()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_stringfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,19 @@ def test_print_string_vector(server_type):
data.append("bla")
field.data = data
d = field.data
print(d)
# print(d)
assert "['bla', 'bla', 'bla'" in d.__str__()
data = []
for _ in range(0, 2):
data.append("bla")
field.data = data
d = field.data
print(d)
# print(d)
assert "['bla', 'bla']" in d.__str__()
data = []
field.data = data
d = field.data
print(d)
# print(d)
d.__str__()


Expand Down

0 comments on commit 47bf517

Please sign in to comment.