由于我正在开发软件包,所以我将工厂设置为这样的自定义路径:
-- app
-- packages
-----mockizart
-------blog
---------database
--------------factories
----------------- PageModelFactory.php
---------src
这是我在服务提供商中加载工厂的方式(我已经通过在phpstorm中单击路径来确保路径正确):
function boot()
{
Factory::construct($this->app->make(\Faker\Generator::class), __DIR__."/../database/factories");
}
这是我的页面模型工厂(我已经确保确实加载了此文件):
<?php
/** @var \Illuminate\Database\Eloquent\Factory $factory */
use Mockizart\Blog\Dodols\PageModel;
use Faker\Generator as Faker;
$factory->define(PageModel::class, function (Faker $faker) {
return [
'name' => "retretre",
'slug' => "retretret",
'type' => 0,
'category' => 0,
'tags' => "",
'content' => "",
];
});
这是我的脚本测试:
use Mockizart\Blog\Dodols\PageModel;
.....
.....
/** @test */
public function edit_page()
{
dd(PageModel::find(1)); <-- this return was NULL so I think my class and namespace does exist.
factory(PageModel::class)->make(); <-- this cause error "unable to locate factory......"
$response = $this->get('/blog/page/edit/15');
$response->assertStatus(200);
}
答案 0 :(得分:0)
因此,如果您使用的是import numpy as np
import sys
import os
from load_images import load, File
import matplotlib.pyplot as plt
from matplotlib import cm
arr_spe = [x for x in os.listdir() if x.endswith(".SPE")]
for x in arr_spe:
try:
dat = load(x)
plt.imshow(dat,cmap=cm.jet, vmax = 2000)
plt.colorbar()
plt.savefig(x[:-4]+'.png', dpi=500, bbox_inches='tight')
except ValueError as error:
print('ValueError(empty)-'+x)
,则加载自定义工厂的正确方法是Test类的orchestra\Testbench
方法或{{1}中的TestCase NOt }。
代码如下:
setUp()