Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Add regression test for issue 327
Browse files Browse the repository at this point in the history
Currently fails with:

    ---- test_python_safe_dump stdout ----
    thread 'test_python_safe_dump' panicked at 'called `Result::unwrap()` on an `Err` value:
    Error("foo: invalid type: integer `7200`, expected u32", line: 1, column: 8)', tests/test_de.rs:17:54
  • Loading branch information
dtolnay committed Sep 14, 2022
1 parent f08c55e commit 7ba2631
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,3 +569,28 @@ fn test_empty_scalar() {
};
test_de(yaml, &expected);
}

#[test]
fn test_python_safe_dump() {
#[derive(Deserialize, PartialEq, Debug)]
struct Frob {
foo: u32,
}

// This matches output produces by PyYAML's `yaml.safe_dump` when using the
// default_style parameter.
//
// >>> import yaml
// >>> d = {"foo": 7200}
// >>> print(yaml.safe_dump(d, default_style="|"))
// "foo": !!int |-
// 7200
//
let yaml = indoc! {r#"
"foo": !!int |-
7200
"#};

let expected = Frob { foo: 7200 };
test_de(yaml, &expected);
}

0 comments on commit 7ba2631

Please sign in to comment.