import attendence_sys.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('attendence_sys', '0004_auto_20200626_2227'),
]
operations = [
migrations.AlterField(
model_name='faculty',
name='profile_pic',
field=models.ImageField(blank=True, null=True, upload_to=attendence_sys.models.user_directory_path),
),
]
Related
I have following structure of tests:
tests
|__element
| |__test_create.py
| |__test_delete.py
| |__test_get.py
| |__test_recover.py
| |__test_update.py
|__conftest.py
I have fixture in conftest.py which must take the same value throughout the session:
#pytest.fixture(scope="session")
async def workspace_locales_set() -> list[str]:
random_locales_subset = random.sample(list(LOCALES_ALLOWED.keys()), random.randint(3, 7))
print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", random_locales_subset)
return random_locales_subset
But all the tests, in test_update fall down because there comes a different locales value.
By the method of many prints, I found out that at the moment of switching from test_recover to test_update`, the fixture is calculated a second time
Here is tests report:
collecting ... collected 893 items
test_create.py::TestElementCreateFieldName::test_name_value_locales_allowed
test_create.py::TestElementCreateFieldName::test_name_value_locales_not_allowed
...
test_delete.py::TestElementsDeleteExisting::test_element_existing_after_deletion[True]
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ['sv-FI', 'gsw-CH', 'zh-Hant-TW']
PASSED [ 0%] PASSED [ 1%]
...
test_create.py::TestElementCreateFieldAttributesFileInput::test_attrs_file_allowed_file_types_is_not_enum_item PASSED [ 5%]
test_delete.py::TestElementsSoftDeleteFieldIsDeleted::test_element_is_deleted PASSED [ 18%]PASSED [ 18%]
test_get.py::TestElementsGetFieldName::test_name_value PASSED [ 19%]PASSED [ 19%]PASSED [ 20%]PASSED [ 20%]
test_recover.py::TestElementsRecoverFieldIsDeleted::test_element_is_deleted
test_recover.py::TestElementsRecoverAccessRights::test_recovering_by_user_not_in_parent_workspace
test_update.py::TestElementsUpdateName::test_update_name_value PASSED [ 24%]PASSED [ 24%]PASSED [ 24%]PASSED [ 24%]PASSED [ 24%]PASSED [ 24%]PASSED [ 24%]
ERROR [ 24%]
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ['es-CL', 'kn', 'xog', 'es-PY', 'hi-IN', 'en-AS', 'en-TT']
As you can see, here is something weird: first the creation tests are run, then one deletion test, then the fixture is computed the first time, then the rest of the run tests go, and between the recovery tests and the deletion test the fixture is computed the second time
I use pytest-asyncio with asyncio_mode = auto. Could it have any effect?
But anyway, the session fixture should be calculated only once. What am I doing wrong?
Okay, that was really stupid. My PyCharm automatically added from conftest import workspace_locales_set in test_update file, so the fixture was called twice.
To fix it just delete all imports from conftest
import attendence_sys.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('attendence_sys', '0004_auto_20200626_2227'),
]
operations = [
migrations.AlterField(
model_name='faculty',
name='profile_pic',
field=models.ImageField(blank=True, null=True, upload_to=attendence_sys.models.user_directory_path),
),
]
File "c:\Users\hasif\OneDrive\Documents\Face_Verification_based_Attendance_system-master\attendence_sys\migrations\0005_auto_20200626_2245.py",
line 3, in
import attendence_sys.models
ModuleNotFoundError: No module named 'attendence_sys'
Im trying to add the finagle-http library to my new bazel project as an external maven dependency. But getting the following error. I assume im doing something wrong in creating the build without fully understanding it. Trying to learning. Appreciate any help on this.
error: object Service is not a member of package com.twitter.finagle
error: object util is not a member of package com.twitter
error: type Request is not a member of package com.twitter.finagle.http
error: object Response is not a member of package com.twitter.finagle.http
error: Symbol 'type com.twitter.finagle.Client' is missing from the classpath. This symbol is required by 'object com.twitter.finagle.Http'.
error: not found: value Await
The same code is working using sbt. Below is the code.
import com.twitter.finagle.{Http, Service}
import com.twitter.finagle.http
import com.twitter.util.{Await, Future}
object HelloWorld extends App {
val service = new Service[http.Request, http.Response] {
def apply(req: http.Request): Future[http.Response] =
Future.value(http.Response(req.version, http.Status.Ok))
}
val server = Http.serve(":8080", service)
Await.ready(server)
}
WORKSPACE file
maven_install(
artifacts = [
"org.apache.spark:spark-core_2.11:2.4.4",
"org.apache.spark:spark-sql_2.11:2.4.1",
"org.apache.spark:spark-unsafe_2.11:2.4.1",
"org.apache.spark:spark-tags_2.11:2.4.1",
"org.apache.spark:spark-catalyst_2.11:2.4.1",
"com.twitter:finagle-http_2.12:21.8.0",
],
repositories = [
"https://repo.maven.apache.org/maven2/",
"https://repo1.maven.org/maven2/",
]
)
BUILD file
load("#io_bazel_rules_scala//scala:scala.bzl", "scala_binary")
package(default_visibility = ["//visibility:public"])
scala_binary(
name="helloworld",
main_class="microservices.HelloWorld",
srcs=[
"Main.scala",
],
deps = ["spark],
)
java_library(
name = "spark",
exports = [
"#maven//:com_twitter_finagle_http_2_12_21_8_0",
],
)
Working SBT dependency that was working in my initial sbt project
libraryDependencies += "com.twitter" %% "finagle-http" % "21.8.0"
Figured out the issue, unlike in sbt, in bazel i had induvidualy add the related dependencies. I modified the workspace as below.
maven_install(
artifacts = [
"com.twitter:finagle-http_2.12:21.8.0",
"com.twitter:util-core_2.12:21.8.0",
"com.twitter:finagle-core_2.12:21.8.0",
"com.twitter:finagle-base-http_2.12:21.8.0",
"com.fasterxml.jackson.module:jackson-module-scala_2.12:2.11.2",
"com.fasterxml.jackson.core:jackson-databind:2.11.2",
],
repositories = [
"https://repo.maven.apache.org/maven2/",
"https://repo1.maven.org/maven2/",
]
Build file --
java_library(
name = "finagletrial",
exports = [
"#maven//:com_twitter_finagle_http_2_12_21_8_0",
"#maven//:com_twitter_util_core_2_12_21_8_0",
"#maven//:com_twitter_finagle_core_2_12_21_8_0",
"#maven//:com_twitter_finagle_base_http_2_12_21_8_0",
"#maven//:com_fasterxml_jackson_module_jackson_module_scala_2_12_2_11_2",
"#maven//:com_fasterxml_jackson_core_jackson_databind_2_11_2"
],
I am using Bazel to compile scala.
Right now, my scala_test looks like
scala_test {
name = "sample",
srcs = [
"a.scala",
"b.scala",
"c.scala",
"d.scala",
],
deps = [
"//src//main/scala/.../dep1",
"//src//main/scala/.../dep2",
"//src//main/scala/.../dep3",
"//src//main/scala/.../dep4",
]
}
In this case, Bazel does not support parallelization on these srcs as they are grouped as one scala_test. To enable automatic parallel testing, I would like to separate srcs into different scala_test like
scala_test {
name = "sample1",
srcs = [
"a.scala",
],
deps = [
"//src//main/scala/.../dep1",
"//src//main/scala/.../dep2",
"//src//main/scala/.../dep3",
"//src//main/scala/.../dep4",
]
}
scala_test {
name = "sample2",
srcs = [
"b.scala",
],
deps = [
"//src//main/scala/.../dep1",
"//src//main/scala/.../dep2",
"//src//main/scala/.../dep3",
"//src//main/scala/.../dep4",
]
}
...
The problem is I guess bazel tries to compile the deps for every scala_test. Is there any way to group dependencies and reuse them in different scala_test blocks such as scala_library?
Sorry, I think Bazel caches the dependencies so I don't have to worry about compiling them again when running all tests.
I try to add Unit tests to my Swift project on Linux Ubuntu 16.04. Now I have the directory structure:
MyProject
|-Sources
| └MyProject
| |-IPcalc.swift
| └ main.swift
|
|-Tests
| |-MyProjectTests
| | └IPcalcTests.swift
| └ LinuxMain.swift
|
└ Package.swift
IPcalcTests.swift file:
import XCTest
#testable import IPcalc
...
LinuxMain.swift file:
import XCTest
#testable import IPcalcTests
XCTMain([
testCase(IPcalcTests.allTests),
])
Package.swift file:
import PackageDescription
let package = Package(
name: "MyProject",
products: [],
dependencies: [],
targets: [
.target(
name: "MyProject",
dependencies: []),
.testTarget(
name: "MyProjectTests",
dependencies: ["MyProject"]),
]
)
When I try to execute swift test , I get:
$ swift test
Compile Swift Module 'MyProjectTests' (2 sources)
/home/user/MyProject/Tests/MyProjectTests/IPcalcTests.swift:2:18: error: no such module 'IPcalc'
#testable import IPcalc
Why I could not import IPcalc class to IPcalcTests.swift?
Issue happens because my app is executable, it has main.swift file. Unit Test don't work in this case, or I don't know how to use it. It is necessary to split project into projectApp target and projectLib target. projectApp will contain only main.swift and projectLib will contain the rest.
After that Unit Test works without any problems with projectLib target. More details about is here: https://riis.com/blog/swift-unit-testing-ubuntu/
https://www.raywenderlich.com/1072244-server-side-swift-testing-on-linux