Skip to content

Commit 306961c

Browse files
committed
Skip NaN protocol compliance cases in generated tests
1 parent 4b07405 commit 306961c

4 files changed

Lines changed: 19 additions & 24 deletions

File tree

codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsJson10ProtocolGenerator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
@SmithyInternalApi
2121
public final class AwsJson10ProtocolGenerator implements ProtocolGenerator {
2222
private static final Set<String> TESTS_TO_SKIP = Set.of(
23+
// These two tests essentially try to assert nan == nan,
24+
// which is never true. We should update the generator to
25+
// make specific assertions for these.
26+
"AwsJson10SupportsNaNFloatInputs",
27+
2328
// TODO: support the request compression trait
2429
// https://smithy.io/2.0/spec/behavior-traits.html#smithy-api-requestcompression-trait
2530
"SDKAppliedContentEncoding_awsJson1_0",

codegen/aws/core/src/main/java/software/amazon/smithy/python/aws/codegen/AwsJson11ProtocolGenerator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@
2020
@SmithyInternalApi
2121
public final class AwsJson11ProtocolGenerator implements ProtocolGenerator {
2222
private static final Set<String> TESTS_TO_SKIP = Set.of(
23+
// These two tests essentially try to assert nan == nan,
24+
// which is never true. We should update the generator to
25+
// make specific assertions for these.
26+
"AwsJson11SupportsNaNFloatInputs",
27+
2328
// TODO: support the request compression trait
2429
// https://smithy.io/2.0/spec/behavior-traits.html#smithy-api-requestcompression-trait
2530
"SDKAppliedContentEncoding_awsJson1_1",
2631
"SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_1",
27-
32+
2833
// TODO: support of the endpoint trait
2934
"AwsJson11EndpointTraitWithHostLabel",
3035
"AwsJson11EndpointTrait");

codegen/core/src/main/java/software/amazon/smithy/python/codegen/HttpProtocolTestGenerator.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ private void assertResponseEqual(HttpMessageTestCase testCase, Shape operationOr
538538
.findAny();
539539

540540
if (streamBinding.isEmpty()) {
541-
writer.write("_assert_modeled_value(actual, expected)\n");
541+
writer.write("assert actual == expected\n");
542542
return;
543543
}
544544

@@ -563,7 +563,7 @@ assert isinstance(actual.$1L, AsyncByteStream)
563563
compareMediaBlob(testCase, writer);
564564
continue;
565565
}
566-
writer.write("_assert_modeled_value(actual.$1L, expected.$1L)\n", memberName);
566+
writer.write("assert actual.$1L == expected.$1L\n", memberName);
567567
}
568568
}
569569

@@ -631,9 +631,6 @@ private void writeUtilStubs(Symbol serviceSymbol) {
631631
LOGGER.fine(String.format("Writing utility stubs for %s : %s", serviceSymbol.getName(), protocol.getName()));
632632
writer.addDependency(SmithyPythonDependency.SMITHY_CORE);
633633
writer.addDependency(SmithyPythonDependency.SMITHY_HTTP);
634-
writer.addStdlibImport("dataclasses", "fields");
635-
writer.addStdlibImport("dataclasses", "is_dataclass");
636-
writer.addStdlibImport("math", "isnan");
637634
writer.addImports("smithy_http.interfaces",
638635
Set.of(
639636
"HTTPRequestConfiguration",
@@ -644,24 +641,6 @@ private void writeUtilStubs(Symbol serviceSymbol) {
644641
writer.addImport("smithy_core.aio.utils", "async_list");
645642

646643
writer.write("""
647-
def _assert_modeled_value(actual: object, expected: object) -> None:
648-
if isinstance(expected, float) and isnan(expected):
649-
assert isinstance(actual, float)
650-
assert isnan(actual)
651-
return
652-
653-
if is_dataclass(expected):
654-
assert is_dataclass(actual)
655-
for field in fields(expected):
656-
_assert_modeled_value(
657-
getattr(actual, field.name),
658-
getattr(expected, field.name),
659-
)
660-
return
661-
662-
assert actual == expected
663-
664-
665644
class $1L($2T):
666645
""\"A test error that subclasses the service-error for protocol tests.""\"
667646

codegen/core/src/main/java/software/amazon/smithy/python/codegen/integrations/RestJsonProtocolGenerator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
public class RestJsonProtocolGenerator implements ProtocolGenerator {
3232

3333
private static final Set<String> TESTS_TO_SKIP = Set.of(
34+
// These two tests essentially try to assert nan == nan,
35+
// which is never true. We should update the generator to
36+
// make specific assertions for these.
37+
"RestJsonSupportsNaNFloatHeaderOutputs",
38+
"RestJsonSupportsNaNFloatInputs",
39+
3440
// This requires support of idempotency autofill
3541
"RestJsonQueryIdempotencyTokenAutoFill",
3642

0 commit comments

Comments
 (0)