|
1 | 1 | from __future__ import unicode_literals
|
2 | 2 |
|
| 3 | +import random |
| 4 | + |
3 | 5 | from pathlib import Path
|
4 | 6 |
|
5 | 7 | import pytest
|
@@ -280,3 +282,30 @@ def test_to_dependency_for_url():
|
280 | 282 | assert "https://example.com/path.tar.gz" == dep.url
|
281 | 283 | assert "url" == dep.source_type
|
282 | 284 | assert "https://example.com/path.tar.gz" == dep.source_url
|
| 285 | + |
| 286 | + |
| 287 | +def test_package_clone(f): |
| 288 | + # TODO(nic): this test is not future-proof, in that any attributes added |
| 289 | + # to the Package object and not filled out in this test setup might |
| 290 | + # cause comparisons to match that otherwise should not. A factory method |
| 291 | + # to create a Package object with all fields fully randomized would be the |
| 292 | + # most rigorous test for this, but that's likely overkill. |
| 293 | + p = Package( |
| 294 | + "lol_wut", |
| 295 | + "3.141.5926535", |
| 296 | + pretty_version="③.⑭.⑮", |
| 297 | + source_type="git", |
| 298 | + source_url="http://some.url", |
| 299 | + source_reference="fe4d2adabf3feb5d32b70ab5c105285fa713b10c", |
| 300 | + source_resolved_reference="fe4d2adabf3feb5d32b70ab5c105285fa713b10c", |
| 301 | + features=["abc", "def"], |
| 302 | + develop=random.choice((True, False)), |
| 303 | + ) |
| 304 | + p.files = (["file1", "file2", "file3"],) |
| 305 | + p.homepage = "https://some.other.url" |
| 306 | + p.repository_url = "http://bug.farm" |
| 307 | + p.documentation_url = "http://lorem.ipsum/dolor/sit.amet" |
| 308 | + p2 = p.clone() |
| 309 | + |
| 310 | + assert p == p2 |
| 311 | + assert p.__dict__ == p2.__dict__ |
0 commit comments