Why am I unable to import a local project module into a unit test module (Python3.9)? - python-import

I have a unit test project in Python 3.9 which is contained within a Visual Studio 2019CE project. This project needs to target Azure Data Factory. To talk to Azure Data Factory there is supporting modules/classes that need to be imported into the unit test module. When importing the supporting objects into a unit test module, the unit test module is no longer discoverable by test explorer.
Import command:
from tools.adf_client import ADFClient
What can I import:
import pyodbc
What is the difference?
pyodbc is installed and tools.adf_client is not, it is a file in the unit test project.
What I have tried:
I tried putting an empty module in the same directory as the unit test module and importing that into the unit test module. The unit test module is still not discoverable.
I have seen examples of people modifying the path. Other people have commented that this is not good practice.
Possible solution:
Creating a setup.py and installing supporting packages into the environment prior to unit-test project execution. This assumes that the problem is that the module is not installed.

Related

Code coverage with clang-cl compiler using llvm-cov generates report with tests files coverage missing

I am trying to get code coverage for a c/c++ llvm-clang project in visual studio IDE which is compiled as a static library and I have a test project written using Gtest to test the static library containing different source files, I can generate a coverage report using command llvm-cov.exe report "my-exe" -instr-profile=*.profdata but the report contains all the files except the files for which I have written the test cases. It simply ignores those files in the coverage.
I have used flags -fprofile-instr-generate, -fcoverage-mapping, and --coverage during the compilation of the static lib code. And it seems to generate .gcno and .gcda files as well. Why are the files for which the test cases written getting ignored?
Please note that the codes are compiled in Visual Studio IDE.Any help is appreciated.

Importing Axe DevTools into iOS Unit Tests and UITests

When I import DevTools the app builds fine, but the unit tests give an error when building:
Module compiled with Swift 5.1.2 cannot be imported by the Swift 5.2.4 compiler:
....../Carthage/Build/iOS/Attest.framework/Modules/Attest.swiftmodule/x86_64-apple-ios-simulator.swiftmodule
If I only import it in our unit tests, then the unit tests build fine, but the app gives an error:
Module compiled with Swift 5.1.2 cannot be imported by the Swift 5.2.4 compiler:
......./Carthage/Build/iOS/Attest.framework/Modules/Attest.swiftmodule/x86_64-apple-ios-simulator.swiftmodule
Is manual testing and unit testing in the same build possible?
This is strange to me. Axe DevTools supports manual and automated testing in the same build. The errors described implies to me that there are multiple versions of Axe DevTools somewhere in your project files, and Xcode is doing some weird things to try to import the wrong version. I would recommend first ensuring that there is only one Axe DevTools framework in your project files. You should be able to use the same framework for both manual and unit testing.
If you do in fact only have one framework, then I would recommend looking through Build Settings for the app and unit tests and ensuring that Framework Search Paths is correct.

How can I use dart ffi properly in a pub package?

I am currently building a console package with Dart, and Rust using FFI(foreign function interface). Since I can't/shouldn't publish dll/so/dylib files, how can I add a build functionality to it. With that functionality, the required files should be built after the package is downloaded, so that the interop-ed code can work properly. How can it be done? Will the user that downloaded the package need to have Rust in his machine to build the files?
You need to either distribute binaries or require the user to have a Rust compiler.

Newbie / Ballerina Build with gson issue while running the build

I am a newbie in Ballerina.
I am importing a platform lib as a executable jar , which is an inter op method call in java using openstack swift api using jclouds.
There has been a known issue with JCLOUDS where it fails to build due to gson version issues higher than 2.5 not compatible with jclouds
Apache jclouds java.lang.NoSuchMethodError when using Rackspace in a Spring Boot application.
I face the same error when trying to execute this inter op method call from my bal file which was built during ballerina build. Upon inspection of the jar, which ballerina created during the build of the project , it shows that the jar is created with a set of prebuilt dependencies with gson 2.7.
is there any way i can change this dependency , i am not also very clear on how ballerina packages all this jars during the build phase of bal files.
It will help to have a detailed understanding on what happens below the hood when ballerina build is invoked.
The following GitHub issue explains why we had to package com.google:gson:2.7 with any Ballerina executable jar.
https://github.com/ballerina-platform/ballerina-lang/issues/17878
Let me try to explain why Ballerina compiler packages some third-party jars with the executable jar created for your Ballerina program. We can categorize these third-party jars into two main categories.
Jar dependencies of the Ballerina runtime
Jar dependencies of each Ballerina module that you've imported in your program.
Dependencies of the Ballerina runtime
Every Ballerina executable program contains the Ballerina runtime - the bare minimum layer on top of the JVM that is required to execute any Ballerina program. Runtime contains the Java implementations of Ballerina values, types, Ballerina modules in the lang lib, and the runtime type checker logic. This layer is essential to enforce Ballerina language semantics on top of the JVM.
At the moment, Ballerina runtime depends on many third-party Java libraries. GSON is one such library that we are planning to remove soon. You can get more details from the above issue.
Dependencies of a Ballerina module
Each Ballerina module, whether it belongs to the standard library or whether you pulled it from the Ballerina central, may depend on one or more third-party Java libraries. The Ballerina module author lists these dependencies in Ballerina.toml of the project in which they develop the Ballerina module. Here are some examples.
ballerina/http
ballerina/kafka
While I was working on this answer, I realized the requirement of a debugging tool that emits the details of third-party libraries. It would be nice if this tool can be integrated into the ballerina command-line tool. Here is the issue that I've created to track this.
https://github.com/ballerina-platform/ballerina-lang/issues/20116
Does upgrading to jclouds 2.2.0 resolve your symptoms? It includes JCLOUDS-1500 which upgrades the gson dependency to 2.8.5.

How can I use FsCheck with a portable class library?

How can I use FsCheck with a portable class library?
I receive the following error:
Error Could not install package 'FsCheck.Xunit 2.5.0'. You are trying
to install this package into a project that targets
'.NETPortable,Version=v4.5,Profile=Profile7', but the package does not
contain any assembly references or content files that are compatible
with that framework. For more information, contact the package author.
Does this mean FsCheck is not PCL compliant?

Resources