<commit_before>package commands

import (
	"os"
	"strconv"

	"github.com/spf13/cobra"
	"github.com/spf13/viper"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	cfg "github.com/tendermint/tendermint/config"
	"github.com/tendermint/tmlibs/cli"

	"testing"
)

var (
	defaultRoot = os.ExpandEnv("$HOME/.some/test/dir")
)

const (
	rootName = "root"
)

// isolate provides a clean setup and returns a copy of RootCmd you can
// modify in the test cases
func isolate(cmds ...*cobra.Command) cli.Executable {
	viper.Reset()
	config = cfg.DefaultConfig()
	r := &cobra.Command{
		Use:               rootName,
		PersistentPreRunE: RootCmd.PersistentPreRunE,
	}
	r.AddCommand(cmds...)
	wr := cli.PrepareBaseCmd(r, "TM", defaultRoot)
	return wr
}

func TestRootConfig(t *testing.T) {
	assert, require := assert.New(t), require.New(t)

	// we pre-create a config file we can refer to in the rest of
	// the test cases.
	cvals := map[string]string{
		"moniker":   "monkey",
		"fast_sync": "false",
	}
	// proper types of the above settings
	cfast := false
	conf, err := cli.WriteDemoConfig(cvals)
	require.Nil(err)

	defaults := cfg.DefaultConfig()
	dmax := defaults.P2P.MaxNumPeers

	cases := []struct {<commit_msg>Do some cleanup in the test, so it doesn't fail in my shell<commit_after>package commands

import (
	"os"
	"strconv"

	"github.com/spf13/cobra"
	"github.com/spf13/viper"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	cfg "github.com/tendermint/tendermint/config"
	"github.com/tendermint/tmlibs/cli"

	"testing"
)

var (
	defaultRoot = os.ExpandEnv("$HOME/.some/test/dir")
)

const (
	rootName = "root"
)

// isolate provides a clean setup and returns a copy of RootCmd you can
// modify in the test cases
func isolate(cmds ...*cobra.Command) cli.Executable {
	os.Unsetenv("TMHOME")
	os.Unsetenv("TM_HOME")
	os.Unsetenv("TMROOT")
	os.Unsetenv("TM_ROOT")

	viper.Reset()
	config = cfg.DefaultConfig()
	r := &cobra.Command{
		Use:               rootName,
		PersistentPreRunE: RootCmd.PersistentPreRunE,
	}
	r.AddCommand(cmds...)
	wr := cli.PrepareBaseCmd(r, "TM", defaultRoot)
	return wr
}

func TestRootConfig(t *testing.T) {
	assert, require := assert.New(t), require.New(t)

	// we pre-create a config file we can refer to in the rest of
	// the test cases.
	cvals := map[string]string{
		"moniker":   "monkey",
		"fast_sync": "false",
	}
	// proper types of the above settings
	cfast := false
	conf, err := cli.WriteDemoConfig(cvals)
	require.Nil(err)

	defaults := cfg.DefaultConfig()
	dmax := defaults.P2P.MaxNumPeers

	cases := []struct {
{'fraction_non_alphanumeric': 0.1435700575815739, 'fraction_numerical': 0.003838771593090211, 'mean_word_length': 3.825925925925926, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4315385', 'n_tokens_mistral': 1023, 'n_tokens_neox': 996, 'n_words': 224}