Skip to content

Commit 0ff7eab

Browse files
authored
Enable test_calendar (#1065)
* Enable test_calendar * Disable test when not in debug mode
1 parent be92a8f commit 0ff7eab

5 files changed

Lines changed: 37 additions & 13 deletions

File tree

Src/IronPython/Hosting/PythonOptionsParser.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ protected override void ParseArgument(string/*!*/ arg) {
7070
LanguageSetup.Options["Verbose"] = ScriptingRuntimeHelpers.True;
7171
break;
7272

73+
case "-I": // both -E and -s
74+
ConsoleOptions.IgnoreEnvironmentVariables = true;
75+
LanguageSetup.Options["IgnoreEnvironment"] = ScriptingRuntimeHelpers.True;
76+
LanguageSetup.Options["NoUserSite"] = ScriptingRuntimeHelpers.True;
77+
break;
78+
7379
case "-S":
7480
ConsoleOptions.SkipImportSite = true;
7581
LanguageSetup.Options["NoSite"] = ScriptingRuntimeHelpers.True;
@@ -250,6 +256,7 @@ public override void GetHelp(out string commandLine, out string[,] options, out
250256
{ "-E", "Ignore environment variables" },
251257
{ "-S", "Don't imply 'import site' on initialization" },
252258
{ "-s", "Don't add user site directory to sys.path" },
259+
{ "-I", "isolate IronPython from the user's environment (implies -E and -s)" },
253260
{ "-t", "Issue warnings about inconsistent tab usage" },
254261
{ "-tt", "Issue errors for inconsistent tab usage" },
255262
{ "-W arg", "Warning control (arg is action:message:category:module:lineno) also IRONPYTHONWARNINGS=arg" },

Src/IronPython/Runtime/Operations/IListOfByteOps.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,22 @@ internal static List<byte> Capitalize(this IList<byte> bytes) {
466466
byte fill = fillchar.ToByteChecked();
467467

468468
List<byte> newBytes = new List<byte>();
469-
for (int i = 0; i < spaces / 2; i++) {
470-
newBytes.Add(fill);
471-
}
472-
473-
newBytes.AddRange(bytes);
474-
for (int i = 0; i < (spaces + 1) / 2; i++) {
475-
newBytes.Add(fill);
469+
if ((width & 1) == 0) {
470+
for (int i = 0; i < spaces / 2; i++) {
471+
newBytes.Add(fill);
472+
}
473+
newBytes.AddRange(bytes);
474+
for (int i = 0; i < (spaces + 1) / 2; i++) {
475+
newBytes.Add(fill);
476+
}
477+
} else {
478+
for (int i = 0; i < (spaces + 1) / 2; i++) {
479+
newBytes.Add(fill);
480+
}
481+
newBytes.AddRange(bytes);
482+
for (int i = 0; i < spaces / 2; i++) {
483+
newBytes.Add(fill);
484+
}
476485
}
477486
return newBytes;
478487
}

Src/IronPython/Runtime/Operations/StringOps.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,14 +407,20 @@ public static string center([NotNull]this string self, int width) {
407407
return center(self, width, ' ');
408408
}
409409

410-
public static string center([NotNull]this string self, int width, char fillchar) {
410+
public static string center([NotNull] this string self, int width, char fillchar) {
411411
int spaces = width - self.Length;
412412
if (spaces <= 0) return self;
413413

414414
StringBuilder ret = new StringBuilder(width);
415-
ret.Append(fillchar, spaces / 2);
416-
ret.Append(self);
417-
ret.Append(fillchar, (spaces + 1) / 2);
415+
if ((width & 1) == 0) {
416+
ret.Append(fillchar, spaces / 2);
417+
ret.Append(self);
418+
ret.Append(fillchar, (spaces + 1) / 2);
419+
} else {
420+
ret.Append(fillchar, (spaces + 1) / 2);
421+
ret.Append(self);
422+
ret.Append(fillchar, spaces / 2);
423+
}
418424
return ret.ToString();
419425
}
420426

Src/IronPythonTest/Cases/CPythonCasesManifest.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ RetryCount=2
201201
Ignore=true
202202

203203
[CPython.test_calendar]
204-
Ignore=true
204+
RunCondition=$(IS_DEBUG) # https://github.com/IronLanguages/ironpython3/issues/1067
205+
Timeout=600000 # 10 minute timeout
205206

206207
[CPython.test_capi]
207208
Ignore=true
@@ -497,7 +498,7 @@ Ignore=true
497498

498499
[CPython.test_heapq]
499500
Ignore=true
500-
Reason=TypeError: __next__() takes exactly 1 argument (1 given)
501+
Reason=TypeError: __next__() takes exactly 1 argument (1 given) # https://github.com/IronLanguages/ironpython3/issues/547
501502

502503
[CPython.test_httplib]
503504
Ignore=true

Src/StdLib/Lib/test/script_helper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def run_python_until_end(*args, **env_vars):
6363
else:
6464
isolated = not env_vars and not env_required
6565
cmd_line = [sys.executable, '-X', 'faulthandler']
66+
if sys.implementation.name == "ironpython": del cmd_line[1:]
6667
if isolated:
6768
# isolated mode: ignore Python environment variables, ignore user
6869
# site-packages, and don't add the current directory to sys.path

0 commit comments

Comments
 (0)