mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Extracted PyRequirementTest
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package com.jetbrains.python;
|
||||
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.packaging.PyPackage;
|
||||
import com.jetbrains.python.packaging.PyRequirement;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public class PyRequirementTest extends PyTestCase {
|
||||
public void testParseRequirement() {
|
||||
assertEquals(new PyRequirement("Django"), PyRequirement.fromString("Django"));
|
||||
assertEquals(new PyRequirement("django"), PyRequirement.fromString("django"));
|
||||
assertEquals(new PyRequirement("Django", "1.3.1"), PyRequirement.fromString("Django==1.3.1"));
|
||||
assertEquals(new PyRequirement("Django", list(new PyRequirement.VersionSpec(PyRequirement.Relation.LT, "1.4"))),
|
||||
PyRequirement.fromString(" Django < 1.4 "));
|
||||
assertEquals(new PyRequirement("Django", list(new PyRequirement.VersionSpec(PyRequirement.Relation.LT, "1.4"),
|
||||
new PyRequirement.VersionSpec(PyRequirement.Relation.GTE, "1.3.1"))),
|
||||
PyRequirement.fromString(" Django < 1.4 , >= 1.3.1 "));
|
||||
assertEquals(null, PyRequirement.fromString("-e lib/django"));
|
||||
assertEquals(new PyRequirement("django", null, "svn+http://code.djangoproject.com/svn/django/trunk@17672", true),
|
||||
PyRequirement.fromString("-e svn+http://code.djangoproject.com/svn/django/trunk@17672#egg=django"));
|
||||
assertEquals(new PyRequirement("django-haystack", "dev", "git://github.com/toastdriven/django-haystack.git@4fb267623b58", true),
|
||||
PyRequirement.fromString("-e git://github.com/toastdriven/django-haystack.git@4fb267623b58#egg=django_haystack-dev"));
|
||||
assertEquals(list(new PyRequirement("django", "1.3"), new PyRequirement("foo")),
|
||||
PyRequirement.parse("# This is a comment\n" +
|
||||
"django==1.3\n" +
|
||||
"--index-url http://example.com/\n" +
|
||||
"foo\n"));
|
||||
}
|
||||
|
||||
// PY-6355
|
||||
public void testTrailingZeroesInVersion() {
|
||||
final PyRequirement req080 = PyRequirement.fromString("foo==0.8.0");
|
||||
final PyPackage pack08 = new PyPackage("foo", "0.8", null, Collections.<PyRequirement>emptyList());
|
||||
assertNotNull(req080);
|
||||
assertTrue(req080.match(list(pack08)) != null);
|
||||
}
|
||||
|
||||
// PY-6438
|
||||
public void testUnderscoreMatchesDash() {
|
||||
final PyRequirement req = PyRequirement.fromString("pyramid_zcml");
|
||||
final PyPackage pkg = new PyPackage("pyramid-zcml", "0.1", null, Collections.<PyRequirement>emptyList());
|
||||
assertNotNull(req);
|
||||
assertTrue(req.match(list(pkg)) != null);
|
||||
}
|
||||
|
||||
// PY-6328
|
||||
public void testNotEditableGitRequirement() {
|
||||
assertEquals(new PyRequirement("django-haystack", "dev", "git://github.com/toastdriven/django-haystack.git@4fb267623b58", false),
|
||||
PyRequirement.fromString("git://github.com/toastdriven/django-haystack.git@4fb267623b58#egg=django_haystack-dev"));
|
||||
}
|
||||
|
||||
// PY-7034
|
||||
public void testMinusInRequirementEggName() {
|
||||
assertEquals(new PyRequirement("django-haystack", null, "git://github.com/toastdriven/django-haystack.git", true),
|
||||
PyRequirement.fromString("-e git://github.com/toastdriven/django-haystack.git#egg=django-haystack"));
|
||||
assertEquals(new PyRequirement("django-haystack", "dev", "git://github.com/toastdriven/django-haystack.git", true),
|
||||
PyRequirement.fromString("-e git://github.com/toastdriven/django-haystack.git#egg=django-haystack-dev"));
|
||||
}
|
||||
|
||||
private static <T> List<T> list(T... xs) {
|
||||
return Arrays.asList(xs);
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,7 @@ public class PythonAllTestsSuite {
|
||||
EpydocStringTest.class,
|
||||
PyEmacsTabTest.class,
|
||||
PyTypeParserTest.class,
|
||||
PyRequirementTest.class,
|
||||
PyOverrideTest.class,
|
||||
PyBinaryModuleCompletionTest.class,
|
||||
PyCompletionPatternsTest.class,
|
||||
|
||||
Reference in New Issue
Block a user