Skip to content

Commit ac77ad0

Browse files
committed
⚰️🧪Remove DisableParallelizationCollectionFixture for some tests
Only tests that manipulate the global, static `UnitsNetSetup.Default.UnitAbbreviations` need to disable parallelization, changes to CurrentCulture is thread-static and is not flaky as long as each test reverts their changes with `CultureScope` or try-finally.
1 parent 0bf57ec commit ac77ad0

File tree

5 files changed

+2
-8
lines changed

5 files changed

+2
-8
lines changed

UnitsNet.Tests/CustomCode/LengthTests.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88

99
namespace UnitsNet.Tests
1010
{
11-
// Avoid accessing static prop DefaultToString in parallel from multiple tests:
12-
// UnitSystemTests.DefaultToStringFormatting()
13-
// LengthTests.ToStringReturnsCorrectNumberAndUnitWithCentimeterAsDefualtUnit()
14-
[Collection(nameof(DisableParallelizationCollectionFixture))]
1511
public class LengthTests : LengthTestsBase
1612
{
1713
protected override bool SupportsSIUnitSystem => true;

UnitsNet.Tests/CustomCode/ParseTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ namespace UnitsNet.Tests
1515
/// reasonable to assume that testing one unit class would cover
1616
/// all of them. Obviously, that can change in the future.
1717
/// </remarks>
18-
[Collection(nameof(DisableParallelizationCollectionFixture))]
1918
public class ParseTests
2019
{
2120
[Theory]

UnitsNet.Tests/QuantityTests.ToString.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace UnitsNet.Tests
1111
{
12-
[Collection(nameof(DisableParallelizationCollectionFixture))]
1312
public partial class QuantityTests
1413
{
1514
public class ToStringTests

UnitsNet.Tests/UnitAbbreviationsCacheTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace UnitsNet.Tests
1111
{
12+
// Disable parallelization due to manipulating global state, like UnitAbbreviationsCache.Default.MapUnitToDefaultAbbreviation().
1213
[Collection(nameof(DisableParallelizationCollectionFixture))]
1314
public class UnitAbbreviationsCacheTests
1415
{
@@ -20,7 +21,7 @@ public class UnitAbbreviationsCacheTests
2021
private static readonly IFormatProvider NorwegianCulture = CultureInfo.GetCultureInfo(NorwegianCultureName);
2122
private static readonly IFormatProvider RussianCulture = CultureInfo.GetCultureInfo(RussianCultureName);
2223

23-
// The default, parameterless ToString() method uses 2 sigifnificant digits after the radix point.
24+
// The default, parameterless ToString() method uses 2 significant digits after the radix point.
2425
[Theory]
2526
[InlineData(0, "0 m")]
2627
[InlineData(0.1, "0.1 m")]

UnitsNet.Tests/UnitParserTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace UnitsNet.Tests
1111
{
12-
[Collection(nameof(DisableParallelizationCollectionFixture))]
1312
public class UnitParserTests
1413
{
1514
[Theory]

0 commit comments

Comments
 (0)