Repository: astral-sh/uv
File: crates/uv-platform-tags/src/abi_tag.rs (Rust)

Code before:
    DuplicateAbiTagSuffix { suffix: char, tag: String },
}

#[cfg(test)]
mod tests {
    use std::str::FromStr;

    use crate::abi_tag::{AbiTag, ParseAbiTagError};

    #[test]
    fn none_abi() {
        assert_eq!(AbiTag::from_str("none"), Ok(AbiTag::None));
        assert_eq!(AbiTag::None.to_string(), "none");
    }

    #[test]
    fn abi3() {
        assert_eq!(AbiTag::from_str("abi3"), Ok(AbiTag::Abi3));
        assert_eq!(AbiTag::Abi3.to_string(), "abi3");
    }

    #[test]
    fn cpython_abi() {
        let tag = AbiTag::from_str("cp39").unwrap();
        assert_eq!(AbiTag::from_str("cp39"), Ok(tag));
        assert_eq!(tag.to_string(), "cp39");
        assert_eq!(tag.pretty(), Some("CPython 3.9".to_string()));

        let tag = AbiTag::from_str("cp37m").unwrap();
        assert_eq!(AbiTag::from_str("cp37m"), Ok(tag));
        assert_eq!(tag.to_string(), "cp37m");
        assert_eq!(tag.pretty(), Some("CPython 3.7".to_string()));

        let tag = AbiTag::from_str("cp313t").unwrap();
        assert_eq!(AbiTag::from_str("cp313t"), Ok(tag));
        assert_eq!(tag.to_string(), "cp313t");
        assert_eq!(tag.pretty(), Some("free-threaded CPython 3.13".to_string()));

        assert_eq!(
            AbiTag::from_str("cpXY"),
            Err(ParseAbiTagError::MissingMajorVersion {
                implementation: "CPython",
                tag: "cpXY".to_string()
            })
        );
    }

    #[test]
    fn pypy_abi() {
        let tag = AbiTag::PyPy {
            python_version: Some((3, 9)),

Review comment (suggestion):
This seems like it should still be creating a tag using `AbiTag::CPython { ... }` otherwise the test case on the very next line doesn't make sense.

Code after:
    DuplicateAbiTagSuffix { suffix: char, tag: String },
}

#[cfg(test)]
mod tests {
    use std::str::FromStr;

    use insta::assert_snapshot;

    use crate::abi_tag::{AbiTag, ParseAbiTagError};

    #[test]
    fn none_abi() {
        assert_eq!(AbiTag::from_str("none"), Ok(AbiTag::None));
        assert_eq!(AbiTag::None.to_string(), "none");
    }

    #[test]
    fn abi3() {
        assert_eq!(AbiTag::from_str("abi3"), Ok(AbiTag::Abi3));
        assert_eq!(AbiTag::Abi3.to_string(), "abi3");
    }

    #[test]
    fn cpython_abi() {
        let tag = AbiTag::from_str("cp39").unwrap();
        assert_eq!(tag.to_string(), "cp39");
        assert_eq!(tag.pretty(), Some("CPython 3.9".to_string()));

        let tag = AbiTag::from_str("cp37m").unwrap();
        assert_eq!(tag.to_string(), "cp37m");
        assert_eq!(tag.pretty(), Some("CPython 3.7".to_string()));

        let tag = AbiTag::from_str("cp313t").unwrap();
        assert_eq!(tag.to_string(), "cp313t");
        assert_eq!(tag.pretty(), Some("free-threaded CPython 3.13".to_string()));

        assert_eq!(
            AbiTag::from_str("cpXY"),
            Err(ParseAbiTagError::MissingMajorVersion {
                implementation: "CPython",
                tag: "cpXY".to_string()
            })
        );
    }

    #[test]
    fn cpython_abi_invalid() {
        let err = AbiTag::from_str("cp39y").unwrap_err();
        assert_snapshot!(err, @"Unknown CPython ABI tag suffix letter `y` for ABI tag: cp39y");