Plt.savefig()在我在终端中调用load_dendro()函数时以正确的大小保存了我的绘图,但是当在类中调用它时,它具有432x288像素。我在Windows上使用python,我的IDE是spyder。屏幕快照在运行完整代码后包含den.png文件,而在仅运行load_dendro函数后包含其中的一部分。 这是我的代码: screenshot
@RunWith(SpringRunner::class)
@SpringBootTest(classes = [(MovieApplication::class)],
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class RestTest {
@LocalServerPort
var port = 0
@Before
@After
fun clean() {
RestAssured.baseURI = "http://localhost"
RestAssured.port = port
RestAssured.basePath = "/movie"
RestAssured.enableLoggingOfRequestAndResponseIfValidationFails()
val list = RestAssured.given().accept(ContentType.JSON).get()
.then()
.statusCode(200)
.extract()
.`as`(Array<MovieDTO>::class.java)
.toList()
list.stream().forEach {
RestAssured.given().pathParam("id", it.id)
.delete("/{id}")
.then()
.statusCode(204)
}
RestAssured.given().get()
.then()
.statusCode(200)
.body("size()", CoreMatchers.equalTo(0))
}
@Test
fun testCreateMovie() {
val title = "title"
val director = "director"
val description = "description"
val info = "info"
val rating = 4
val releaseDate = ZonedDateTime.now()
val dto = MovieDTO(title, director, description, info, rating, releaseDate)
RestAssured.given().accept(MediaType.APPLICATION_JSON_UTF8_VALUE)
.get()
.then()
.statusCode(200)
.body("size()", CoreMatchers.equalTo(0))
val id = RestAssured.given().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.body(dto)
.post()
.then()
.statusCode(201)
.extract().asString()
RestAssured.given().accept(MediaType.APPLICATION_JSON_UTF8_VALUE)
.get()
.then()
.statusCode(200)
.body("size()", CoreMatchers.equalTo(1))
RestAssured.given().accept(MediaType.APPLICATION_JSON_UTF8_VALUE)
.pathParam("id", id)
.get("/{id}")
.then()
.statusCode(200)
.body("title", CoreMatchers.equalTo(title))
.body("director", CoreMatchers.equalTo(director))
.body("description", CoreMatchers.equalTo(description))
.body("info", CoreMatchers.equalTo(info))
.body("rating", CoreMatchers.equalTo(rating))
.body("releaseDate", CoreMatchers.equalTo(releaseDate))
.body("id", CoreMatchers.equalTo(id))
}