Support usage in Jupyter notebooks
See original GitHub issueDescription
When using FluentAssertions in a C# Jupyter notebook and the assertion fails, the exception is not pertaining to the actual mismatch, but regarding missing infrastructure.
Complete minimal example reproducing the issue
Expected behavior:
The expected exception for the above example is:
Expected value to be 99, but found 1.
at FluentAssertions.Execution.LateBoundTestFramework.Throw(String message)
at FluentAssertions.Execution.TestFrameworkProvider.Throw(String message)
at FluentAssertions.Execution.DefaultAssertionStrategy.HandleFailure(String message)
...
Actual behavior:
The actual exception is:
Unhandled Exception
Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (0x80131058)
at FluentAssertions.Common.AppSettingsConfigurationStore.GetSetting(String name)
at FluentAssertions.Common.Configuration.get_ValueFormatterAssembly() in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Common\Configuration.cs:line 88
at FluentAssertions.Common.Configuration.DetermineFormatterDetectionMode() in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Common\Configuration.cs:line 55
at FluentAssertions.Common.Configuration.get_ValueFormatterDetectionMode() in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Common\Configuration.cs:line 40
at FluentAssertions.Formatting.AttributeBasedFormatter.get_IsScanningEnabled() in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Formatting\AttributeBasedFormatter.cs:line 33
at FluentAssertions.Formatting.AttributeBasedFormatter.CanHandle(Object value) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Formatting\AttributeBasedFormatter.cs:line 28
at FluentAssertions.Formatting.Formatter.<>c__DisplayClass7_0.<Format>b__0(IValueFormatter f) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Formatting\Formatter.cs:line 138
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at FluentAssertions.Formatting.Formatter.Format(Object value, FormattingContext context, FormatChild formatChild) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Formatting\Formatter.cs:line 138
at FluentAssertions.Formatting.Formatter.ToString(Object value, Boolean useLineBreaks) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Formatting\Formatter.cs:line 97
at FluentAssertions.Execution.MessageBuilder.<FormatArgumentPlaceholders>b__6_0(Object a) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\MessageBuilder.cs:line 91
at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
at FluentAssertions.Execution.MessageBuilder.FormatArgumentPlaceholders(String failureMessage, Object[] failureArgs) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\MessageBuilder.cs:line 91
at FluentAssertions.Execution.MessageBuilder.Build(String message, Object[] messageArgs, String reason, ContextDataItems contextData, String identifier, String fallbackIdentifier) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\MessageBuilder.cs:line 40
at FluentAssertions.Execution.AssertionScope.<>c__DisplayClass30_0.<FailWith>b__0() in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\AssertionScope.cs:line 200
at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\AssertionScope.cs:line 216
at FluentAssertions.Execution.AssertionScope.FailWith(Func`1 failReasonFunc) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\AssertionScope.cs:line 196
at FluentAssertions.Execution.AssertionScope.FailWith(String message, Object[] args) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Execution\AssertionScope.cs:line 238
at FluentAssertions.Numeric.NumericAssertions`1.Be(T expected, String because, Object[] becauseArgs) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions\Numeric\NumericAssertions.cs:line 51
at Submission#7.<<Initialize>>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmissionsAsync[TResult](ImmutableArray`1 precedingExecutors, Func`2 currentExecutor, StrongBox`1 exceptionHolderOpt, Func`2 catchExceptionOpt, CancellationToken cancellationToken)
The behavior does not change if #r "nuget:System.Configuration.ConfigurationManager"
is added to the cell before loading FluentAssertions.
Versions
- Which version of Fluent Assertions are you using? The latest version downloaded by the
#r
statement. - Which .NET runtime and version are you targeting? The latest .NET Core version installed into the Jupyter Docker image.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Jupyter Notebook
The Jupyter Notebook is a web-based interactive computing platform. The notebook combines live code, equations, narrative text, visualizations, ...
Read more >Jupyter notebook support | PyCharm Documentation
Explore Jupyter notebook support in PyCharm. Learn how to edit, execute, and debug Jupyter notebooks.
Read more >Ultimate Jupyter notebook support - IntelliJ IDEA
Explore Jupyter notebook support in IntelliJ IDEA. Learn how to edit, execute, and debug Jupyter notebooks.
Read more >Working with Jupyter Notebooks in Visual Studio Code
Visual Studio Code supports working with Jupyter Notebooks natively, and through Python code files. This topic covers the native support available for ...
Read more >Jupyter Notebook 7.0.2 documentation
The Jupyter Notebook aims to support the latest versions of these browsers: ... Up to date versions of Opera and Edge may also...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the workaround! I can live with that for now. But a solution to the root problem would be nice, too, of course.😉
Yes, I’m good with the decorator approach.