diff options
author | Raphaël Barrois <raphael.barrois@spacinov.com> | 2023-02-28 11:01:01 +0100 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@spacinov.com> | 2023-02-28 11:01:01 +0100 |
commit | e00fb6da0b0a2cec8fdb8ca89ba78b086157f6dd (patch) | |
tree | e8e96d34d3c6452126286b48303b0293bb16d49b /semantic_version | |
parent | c2ec5114a7865c5fccd745329ecdc34d912d9b74 (diff) | |
download | semantic-version-e00fb6da0b0a2cec8fdb8ca89ba78b086157f6dd.tar.gz |
Test and fix Version.truncate()
Calling `Version.truncate("build")` should return a fresh instance, as
caught in #141
Closes: #141, #142
Diffstat (limited to 'semantic_version')
-rw-r--r-- | semantic_version/base.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/semantic_version/base.py b/semantic_version/base.py index 777c27a..1c10155 100644 --- a/semantic_version/base.py +++ b/semantic_version/base.py @@ -181,7 +181,14 @@ class Version(object): def truncate(self, level='patch'): """Return a new Version object, truncated up to the selected level.""" if level == 'build': - return self + return Version( + major=self.major, + minor=self.minor, + patch=self.patch, + prerelease=self.prerelease, + build=self.build, + partial=self.partial, + ) elif level == 'prerelease': return Version( major=self.major, |